(Software Engineering) Tests & Test Driven Development(TDD)

  •  Tests & Test Driven Development(TDD) :

--Tests are nothing but requirement conditions that we need to test to fulfil them. 

  •    --Test Driven Development (TDD) is software development approach in which          test cases are developed to specify and validate what the code will do. 
  • Test cases for each functionality are created 
  • and tested first 
  • and if the test fails then the new code is written in order to pass the test  
  • and making code simple and bug-free. 

 

  • Test-Driven Development starts with designing and developing tests for every small functionality of an application. 
  • TDD framework instructs developers to write new code only if an automated test has failed. This avoids duplication of code. 
  • Approach is used typically in XP. 

 

NAMING CONVENTIONS FOR WRITING TESTS 


  • Behaviour Driven Development approach is used while naming tests 


  • E.g.: 

    When [ACTION] Then [VERIFICATION] 

  • In this case the name of one of the test method example: 

    When2OrMore@ThenCombineItToSingle(... ) 

    { 

    IF(..) RETURN(.....) 

    RETURN(..) 

    } 

 

TDD CYCLE 


  • Write a test. 
  • Make it run. 
  • Change the code to make it right i.e. Refactor. 
  • Repeat process. 

MYTH CLARIFCATIONS 


  • TDD approach is neither about “Testing” nor about “Design”. 
  • TDD does not mean “write some of the tests, then build a system that passes the tests.” 
  • TDD does not mean “do lots of Testing.” 

 

TDD BENEFITS 

  • Makes finding mistakes easy. 
  • You express your intent twice, once with a test and another with production code. 
  • All these tests are checked in and become part of your continuous integration 

TDD CHALLENGES 


  • It will increase your effort. But should reduce effort at the end of delivery cycle. 
  • If you have legacy code, extra effort and time is required to place hooks for TDD. 
  • The basic steps of TDD are easy to learn, but the mindset takes a while to master. 
  • This is a skill and requires continuous practice to get better. 


Post a Comment

Previous Post Next Post