Top Banner
Data-Driven Transaction Based Unit Tests Engin Yorganc Engin Yorganc ı ı o o ğ ğ lu lu Volkan Sevin Volkan Sevin ç ç ok ok Turkey Turkey
22

Data-Driven Transaction Based Unit Tests Engin Yorgancıoğlu Volkan Sevinçok Turkey.

Dec 31, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Data-Driven Transaction Based Unit Tests Engin Yorgancıoğlu Volkan Sevinçok Turkey.

Data-Driven Transaction Based

Unit Tests

Data-Driven Transaction Based

Unit Tests

Engin YorgancEngin Yorgancııooğğlulu

Volkan SevinVolkan Sevinççokok

TurkeyTurkey

Page 2: Data-Driven Transaction Based Unit Tests Engin Yorgancıoğlu Volkan Sevinçok Turkey.

2

Why automate unit tests?

Automation of unit tests allows regression testing, by which functionality and quality can be continuously tracked.

Page 3: Data-Driven Transaction Based Unit Tests Engin Yorgancıoğlu Volkan Sevinçok Turkey.

3

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.

Page 4: Data-Driven Transaction Based Unit Tests Engin Yorgancıoğlu Volkan Sevinçok Turkey.

4

What do we mean by “transaction”?

“Transaction” in this context refers to the specific transactional operations of the architecture used in the application-under-test, rather than database transactions.

Page 5: Data-Driven Transaction Based Unit Tests Engin Yorgancıoğlu Volkan Sevinçok Turkey.

5

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

Page 6: Data-Driven Transaction Based Unit Tests Engin Yorgancıoğlu Volkan Sevinçok Turkey.

6

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.

Page 7: Data-Driven Transaction Based Unit Tests Engin Yorgancıoğlu Volkan Sevinçok Turkey.

7

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

Page 8: Data-Driven Transaction Based Unit Tests Engin Yorgancıoğlu Volkan Sevinçok Turkey.

8

The Application Framework

Page 9: Data-Driven Transaction Based Unit Tests Engin Yorgancıoğlu Volkan Sevinçok Turkey.

9

DTUT Framework /1

Writing unit tests for each smallest unit was unfeasible due to business constraints.

We take transaction classes as our “test units”.

Page 10: Data-Driven Transaction Based Unit Tests Engin Yorgancıoğlu Volkan Sevinçok Turkey.

10

DTUT Framework /2

Writing trivial unit-tests: as simple as inserting a row in the test database.

Transaction-level unit tests: Achieving high coverage quicklyIntensifying unit tests in critical areas of the

system.

Page 11: Data-Driven Transaction Based Unit Tests Engin Yorgancıoğlu Volkan Sevinçok Turkey.

11

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.

Page 12: Data-Driven Transaction Based Unit Tests Engin Yorgancıoğlu Volkan Sevinçok Turkey.

12

DTUT Framework /4DTUT have wider coverage than the

simplest unit tests, but they still remained more focused than integration-level ones.

Code Generation For Framework To further speed up the process, a code

generation tool is designed and implemented. The generator produces the test class and

creates the test data table in which test cases will added.

Page 13: Data-Driven Transaction Based Unit Tests Engin Yorgancıoğlu Volkan Sevinçok Turkey.

13

DTUT Framework Usage 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 generator tool.

Forming test cases: Each designed test case is entered in the test-data tables as a row.

Page 14: Data-Driven Transaction Based Unit Tests Engin Yorgancıoğlu Volkan Sevinçok Turkey.

14

DTUT Framework Usage 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.

Page 15: Data-Driven Transaction Based Unit Tests Engin Yorgancıoğlu Volkan Sevinçok Turkey.

15

Sample metrics (AUT)Lines of Code : 859,897Total screens: 780Total database tables: 820Methods/Class : 3.2Average Complexity : 3.05

Page 16: Data-Driven Transaction Based Unit Tests Engin Yorgancıoğlu Volkan Sevinçok Turkey.

16

Sample metrics (Testing)4500 Unit Tests with DTUT: 10 developers x 3 Months

For testing a sample entity;Without DTUT: 18 methods in 560 LoCWith DTUT Framework: 2 methods in 50 LoC 18 rows was created in test database where

each row corresponded to a test method.

Page 17: Data-Driven Transaction Based Unit Tests Engin Yorgancıoğlu Volkan Sevinçok Turkey.

17

The team’s approach to testing

Project manager Software project managerDevelopers

Page 18: Data-Driven Transaction Based Unit Tests Engin Yorgancıoğlu Volkan Sevinçok Turkey.

18

DTUT Framework v2

Why need the second version?

How different is it?

Page 19: Data-Driven Transaction Based Unit Tests Engin Yorgancıoğlu Volkan Sevinçok Turkey.

19

DTUT Framework v3

Future work

Page 20: Data-Driven Transaction Based Unit Tests Engin Yorgancıoğlu Volkan Sevinçok Turkey.

20

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.

Page 21: Data-Driven Transaction Based Unit Tests Engin Yorgancıoğlu Volkan Sevinçok Turkey.

21

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).

Page 22: Data-Driven Transaction Based Unit Tests Engin Yorgancıoğlu Volkan Sevinçok Turkey.

22

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.