Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

This is my first question here, so i'll make it short and to the point.

When Writing unit tests, should you write them before or after you have made the underlying framework for them? This came up in a discussion between my CEO and President, and I wanted your opinion on this.

Personally, I have always wrote the code first, then wrote the unit tests, but what about you?

share|improve this question
1  
This is ambiguous. Is it before you write the unit testing framework or before you write a framework that you will be unit testing? –  alternative Oct 14 '10 at 19:41

3 Answers 3

Write the unit tests first - they'll help you define your interfaces - starting from what functionality they expose down to the method signatures.

share|improve this answer

During. You're not going to get an entire framework done in one iteration. Your framework and unit tests should co-evolve simultaneously.

On a more micro scale, tests first, code second.

share|improve this answer

I would have to say unit tests first then coding. Even with the best will in the world, tight deadlines and other priorities will simply mean they will get pushed back or not done at all. Leaving a bigger headache for those who'll have to maintain the codebase.

Besides writing the unit test should help you formulate what your trying to achive.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.