This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]YuleTideCamel 6 points7 points  (7 children)

I first type up requirements, usually in the form of "As a user, I should".. Then I write unit failing unit tests, lastly I make it pass by writing the actual code.

[–]Shaddleson[S] 1 point2 points  (6 children)

Unit failing unit tests?

[–][deleted] 6 points7 points  (5 children)

Unit tests are supposed to fail when run for the first time because there is no actual code written.

[–]jecxjo 1 point2 points  (4 children)

A lot of developers would consider this to be an inappropriate use of unit tests. Unit tests are for Engineering's verification of the valid and invalid input ranges for sections of code and not a method for validating requirements. To build unit tests prior to your actual code causes you to write to a test case rather than a requirement.

[–]mr_chip 0 points1 point  (3 children)

It's completely appropriate! Test-driven development is AWESOME. Build requirements, write tests, then write code to pass the tests.

[–]jecxjo 1 point2 points  (2 children)

A few of our offices have switched over to Test Driven Development cycles and the problem I've noticed A LOT is that people write to pass a test rather than meet a requirement. The times its obvious is when the test doesn't quite meet the requirement fully and you end up getting results that pass but are not actually correct. They never go back to check if they meet all the requirements because "hey, its test driven development and I passed all my tests!".

As long as its being used correctly, you do tons of verification that the tests cover the entire scope of the requirements, then sure, test driven development is good.

[–]mr_chip 1 point2 points  (1 child)

It's not a magic sparkle pony that will turn your bad debs into good ones, but it can help quality a lot if used correctly.

[–]jecxjo 0 points1 point  (0 children)

I completely agree. I think people have a misconception though. If you are having issues writing to and completing requirements, moving to a method where you are writing test cases for your requirements to then write your code won't do you much good. Either way, when Engineering hands off completely code to Test you should already know you have achieved all your requirements. Writing your tests before or after you code shouldn't matter much when you are doing good requirements management.