I have been hearing this "Test Driven Development" from quite a time, People say that we write junittest cases earlier than we write the actual code, I am not sure how does that happens, when we dont have code what do we write test cases for ? also i want to know how to properly use junit in conjction with Agile and XP Programming
Now you have your first test and can start writing production code to make it pass.
Does that help?
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Joined: Mar 02, 2006
I understand what you say , but one doubt you mentioned of : assertEquals(1,factorial(1)); If function factorial does not exists how will my code compile : or do you say that i write all the junit test cases with prototype methods; can you describe me when any requirments comes up for a project ; how should one proceed in for Agile Development Thanks
Something that doesn't compile counts as a failing test, so yes that's a valid starting point. One trick is to keep the cycle very small. Write one test that fails, write enough code to make it pass, repeat.
Robert Martin's Bowling Game Kata is a neat example of test first coding ... even though the solution is not particularly OO.
Note that there is no notion of writing a whole lot of tests up front. You should have some idea where you're going, but just code one at a time. One time you might write a test and not immediately code the solution is quitting time. It's nice to come in the next morning and have a failing test to remind you where you were.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi