230 likes | 485 Views
Data-Driven Transaction Based Unit Tests. Engin Yorganc ı o ğ lu Volkan Sevin ç ok Turkey. Why automate unit tests?. Automation of unit tests allows regression testing, by which functionality and quality can be continuously tracked. 2. What is DTUT ?.
E N D
Data-Driven Transaction Based Unit Tests EnginYorgancıoğlu VolkanSevinçok Turkey
Why automate unit tests? Automation of unit tests allows regression testing, by which functionality and quality can be continuously tracked. 2
What is DTUT? DTUT “Data-Driven Transaction-Based Unit Test”helps fast test development with increased test-case maintainability in applications based on similar architectures to that of application-under-test. 3
What do we mean by “transaction”? “Transaction” in this contextrefers to the specific transactional operations of the architecture used in the application-under-test, rather than database transactions. 4
About Application-Under-Test /1 The application’s architecture similar to Microsoft’s Enterprise Development Reference Architecture (EDRA) Uses ASP.NET and C# on Microsoft Visual Studio 2008 using Oracle 10g database 5
About Application-Under-Test /2 This architecture mainly operates on Request and Response objects communicated through pipelines. Requests are generated upon user interactions with the interface. 6
About Application-Under-Test /3 Transaction objects process the incoming request They generate a Response object to send to the UI Data-access layer classes are created by using an O/R mapping tool 7
DTUT Framework /1 Writing unit tests for each smallest unit was unfeasible due to business constraints. We take transaction classes as our “test units”. 9
DTUT Framework /2 Writing trivial unit-tests: as simple as inserting a row in the test database. Transaction-level unit tests: Achieving high coverage quickly Intensifying unit tests in critical areas of the system. 10
DTUT Framework /3 Uses reflection to execute all transactions in a generic way. Test cases added as rows to test database. Connects to this database and retrieves these rows one by one and executes them. 11
DTUT Framework /4 DTUT have wider coverage than the simplest unit tests, but they still remained more focused than integration-level ones. Code Generation For Framework Tofurtherspeeduptheprocess, a code generation tool is designed and implemented. The generator produces the test class and creates the test data table in which test caseswilladded. 12
DTUT FrameworkUsage and Testing Process /1 Test suite design: The design is made so that it involves positive and negative test cases. Test class and test-data table generation: The test class(es) for the specified unit and table(s) to hold test data are created using the generatortool. Forming test cases: Each designed test case is entered in the test-data tables as a row. 13
DTUT FrameworkUsage and Testing Process /2 Running tests: The tests are run using Visual Studio Team System 2008. Reporting: Visual Studio reports successful and failed tests visually. Each test can be tracked down to its data rows and the reasons for unexpected results can be found easily. If a defect is discovered, it is entered into the defect-tracking system. 14
Sample metrics (AUT) Lines of Code: 859,897 Total screens: 780 Total database tables: 820 Methods/Class : 3.2 AverageComplexity : 3.05 15
Sample metrics (Testing) 4500 Unit Tests with DTUT: 10 developers x 3 Months For testing a sample entity; Without DTUT: 18 methods in 560 LoC WithDTUT Framework: 2 methods in 50 LoC 18 rows was created in test database where each row corresponded to a test method. 16
The team’s approach to testing Project manager Software project manager Developers 17
DTUT Framework v2 Why need the second version? How different is it? 18
DTUT Framework v3 Future work 19
Advantages DTUT Generation reduces trivial unit test generation time to a simple user-interface selection effort and inserting rows to the test. This enables rapid creation of unit-tests which is especially important for testing projects that have sizeable amounts of existing untested code. 20
Limitations DTUT is that its applicable domain covers only projects based on similar frameworks working on .NET architecture, and adhering to certain naming conventions (because of reflection). 21
Conclusion As with all frameworks, DTUT framework can be useful in its own defined scope and domain. Although it is not a silver bullet, it can facilitate rapid production and standardization of unit tests. 22