Home > Software > Testing > Manual-Testing
Interview Questions   Tutorials   Discussions   Programs   Videos   

Manual-Testing - Why do we write test cases?




341
views
asked marvit October 7, 2014 02:37 AM  

Why do we write test cases?


           

1 Answers



 
answered By shallu   0  

Writing tests before implementations is one of the core ideas behind Test Driven Development (TDD). The procedure is: • write a failing test • change the code to make it pass, without breaking any other test • refactor the code, verify that all tests still pass This procedure is the same whether you implement a feature or fix a bug; it is often referred to as "Red-Green-Refactor" (red = test fails, green = test passes). The advantages of this method are numerous: • the test clearly defines what constitutes "done" • the test documents how you intend the code to be used • if you do it right, you build a complete test suite with 100% coverage as a by-product of your development process, which means you always have reliable regression tests at hand no matter what you do • coding to meet a test case (and nothing else) helps keep you focused on one task and prevents feature creep • the red-green-refactor cycle makes for a nice, clean and tracable commit history and fits a feature branch repository approach well (each feature branch starts with a commit that adds a failing test, then one or more commits until "green" is reached, and then one or more refactoring commits). • you produce working versions at regular intervals - ideally, each red-green-refactor cycle ends with a potentially shippable product, but at the very least, it should build without failures and pass all the tests.

Writing tests before implementations is one of the core ideas behind Test Driven Development (TDD). The procedure is: • write a failing test • change the code to make it pass, without breaking any other test • refactor the code, verify that all tests still pass This procedure is the same whether you implement a feature or fix a bug; it is often referred to as "Red-Green-Refactor" (red = test fails, green = test passes). The advantages of this method are numerous: • the test clearly defines what constitutes "done" • the test documents how you intend the code to be used • if you do it right, you build a complete test suite with 100% coverage as a by-product of your development process, which means you always have reliable regression tests at hand no matter what you do • coding to meet a test case (and nothing else) helps keep you focused on one task and prevents feature creep • the red-green-refactor cycle makes for a nice, clean and tracable commit history and fits a feature branch repository approach well (each feature branch starts with a commit that adds a failing test, then one or more commits until "green" is reached, and then one or more refactoring commits). • you produce working versions at regular intervals - ideally, each red-green-refactor cycle ends with a potentially shippable product, but at the very least, it should build without failures and pass all the tests.

flag   
   add comment

Your answer

Join with account you already have

FF

Preview


Ready to start your tutorial with us? That's great! Send us an email and we will get back to you as soon as possible!

Alert