.comment-link {margin-left:.6em;}

Monday, March 27, 2006

 

Data Driven Unit Test


TDD :

You will hear a lot about it in the VSTS era

Test driven development :

It is not testing software ,NO
It is aligning the developers to write more code efficient from customer
point of view

So life cycle would be :
- Write test (what ? Without having a code to test it) yes , write test
projects first . Think from customer point of view: what I need this
software to behave like . For example : I need my method to return
InvalidCustomerIDException when someone passes a null of invalid ID, and
I begin writing the test for the method that doesn't exist yet. So I
force the production in this way to follow the behaviour that I have
already designed in the test

- run test and see it fails . In this way I know that there is something
that must be done in the production code to make the test succeed

- write production code that make the test pass

- run test and see it pass

Ok here comes the main goal for this feed entry :
When I write a unit test , I am writing a static expected value and
calculate the actual value and then compare by Assert .what if I need
these values to be dynamic or having many values ? I will write an array
of course in the test method and loop through the array and invoke the
production code, WRONG.
There is another smart way: Data Driven unit test
I will create a table in the DB , and fill the table with data and tell
the test engine : please invoke my test method number of times equals
the no of rows in the table and pass the value for each row to the test
method every time. Wowwwwwwwwwwwwwwwwwwwwwwwwwwwww magnificent
So any time I can go to the table and change the test data and have
another punch of tested values.


Comments: Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?