lundi 3 août 2015

Some confusion about test driven development

According to wikipedia following are the steps in TDD:

step1: Write a unit test

step2:run the unit test

step3:write code for module

step4:run ALL tests again

step5:clean up code

step6:repeat the steps

Question1 : in TDD we mainly write unit tests. where integration tests and system tests fits in the above steps???

Consider following example:

Suppose we have feature which we have to develop.Then according TDD we will develop this feature in short iterations. suppose we have divided this feature into 2 modules – module1 and module2. I am writing iteration steps for developing these modules in TDD according to above given steps. (Question2)Please correct me where i am wrong in following steps:

Iteration1:

Step1:we write unit test for module 1.

Step2: Run this unit test for module 1(this test would fail)

Step3:Develop code for module 1.

Step4:Run unit tests for module1 again(this test would pass)

Iteration2:

Step1:write unit test for module2

Step2:run unit test for module2

Step3:write code for module2

Step4:run unit tests for module1 and unit tests of module2.(Question3:here in this step why we are running unit tests of module 1 as module 2 is in under test??? if u say that is done because to test that whether module 2 does not break module 1 functionality then my question is that here we are testing only module 2. It is not integrated with module 1 yet so how it will break module1???)

Iteration3:

Step1:create integration tests(Am i right here???)

Step2:run integration tests(it will fail as module 1 and module 2 are not integrated yet)

Step3:Integrate module 1 and module 2

Step4:run all tests(unit tests of module1,module2 and integration tests)

(Question4: why in this step we are running here unit tests of module 1 and 2 ???)

Iteration4(when all modules are integrated):

Step1:create system tests

Step2:run system tests(they will fail)

Step3:(Question 5:)what code to write here as for system testing we do not write any code and according to TDD principles first we write tests then we write development code so what code we will write here???

Aucun commentaire:

Enregistrer un commentaire