TDD , now a widely used jargon at almost all emerging software companys. Now what does TDD offer you? or why should you go for a TDD approach. Well.. for me...it goes this way -
Test Driven Development
• The importance of writing tests
o They force the developer to think of the class design
o They provide a safety harness while refactoring
o They ensure that the state of code is always stable
o New developers can make changes comfortable with the knowledge that if they break something that was working, the tests will inform them
o Test after development is not the same as test first development. Test after development does not reap all the benefits of test first development
• Writing the tests
o Think about the class it’s responsibilities and it’s API
o Write the tests to test every method and various conditions in the methods
o Whenever you think of writing a print statement or generate a log, it might be a scenario to include a test
o Write enough production code to ensure that the tests compile and fail
o Write production code to pass all tests one by one, while also ensuring that previous tests do not fail
• What not to test
o Database entities need not be tested
o Do not go overboard with tests. First write tests that are most likely to fail. Think of the cost benefit ratio while writing tests
• The test class
o Tests classes end with the work Test. The test class for Account will be AccountTest
o Test methods begin with the word test. The test method for creditAccount() will be testcreditAccount()
o Tests can either exist in a different source tree in the same package as the class they are testing, or in the same source tree, but in a different package.
• Managing dependencies
o Unit tests should ideally not have any dependencies
o Dependencies can be eliminated with mock objects (so that units can be tested in isolation)
• AllTests
o There should have one class AllTests that will run the entire test suite
Requirements (Java Unit Tests):
• JUnit 3.8 for JDK 1.4 and before
• JUnit 4.x for JDK 1.5 and after
• StrutsTestCase for testing Struts Action classes
English Premier League
Bundesliga
La Liga
Showing posts with label Test Driven Developement. Show all posts
Showing posts with label Test Driven Developement. Show all posts
10:32 PM
Test Driven Developement
Monday, November 17, 2008
Subscribe to:
Posts (Atom)

