SpecFlow - Test Driven Development



A Test-Driven Development is also known as the TDD. It consists of the below steps to be followed one-by-one −

Step 1 − Create a Test.

Step 2 − Verify if the test fails.

If the test passes, create the second test.

If the test fails, then move to Step 3.

Step 3 − Fix the test to make it pass.

If the test passes, move to Step 4.

If the test fails, then jump to Step 3.

Step 4 − Start code refractor and redo all the above steps till the development is done.

Benefits of TDD

The benefits of TDD are listed below −

  • The developer is required to apprehend the requirements to know what the outcome of a scenario should be and how to test it.

  • The implementation for a module is done only if all the test cases pass and code refactoring is complete. Thus, verification and refactoring should be done prior to moving it to the next test.

  • After refactoring is done, the unit test suite is to run.

  • The unit tests can be used as a live documentation.

  • If a bug is found, a test is created to get the details of the bug. The script is updated, to pass the tests. Simultaneously, the other tests are also executed to ensure that existing features are not broken by the fix.

  • A developer can participate in design decisions and improve it anytime during the test execution stage to ensure the application is working correctly. This is done to increase the maintainability of the product.

  • A developer is sure of making any modifications. This is because if that affects any existing feature, it shall be reflected by executing the tests. This way bugs can be addressed quickly.

  • On running the tests in succession¸ all the prior bug fixes are also verified, and the similar bugs can be avoided.

  • Since major testing is conducted during the development phase, the test duration required prior to delivery is short.

Drawbacks of TDD

The drawbacks of TDD are listed below −

  • The developers find it difficult to decide when to start testing.

  • The developers get confused on what to test.

  • The developers do not know if all the requirement specifications are being covered.

  • The developers are unsure if their code is adding business values.

Myths Around TDD

The myths around TDD are listed below −

Myths

Facts

TDD is only concerned with testing with automation.

TDD is a development technique following the Test First method.

TDD does not consist of design.

TDD has a thorough research and design depending on the requirements. The design is completed during the development phase.

TDD is done only for unit testing.

TDD is done for system and integration testing as well.

TDD cannot be adopted for orthodox test projects.

TDD is used for Agile development. But it can be adopted for conventional test projects as well.

TDD is considered a tool.

TDD is a development technique and post every new unit test pass, it is clubbed with the automation suite which is run whenever there is a modification in the code and post refactoring activity.

Advertisements