Test Not First

From
http://www.simple-talk.com/dotnet/.net-framework/on-writing-unit-tests-for-c/

A practice that is made popular by Agile and Extreme Programming methodologies is ‘test-first development’. From Wikipedia: ‘The tests should be written before the functionality that is being tested’.

I don’t agree with that. Tests for a portion of code should be written at the same time as the code itself. I advocate this because not all edge cases can be faced up-front, even by domain experts or professional testers. Edge cases are generally discovered only when thoroughly implementing an algorithm. This is an iterative process where you write a few tests, then write the few corresponding lines of code and methods, and repeat until the features and classes are completely implemented and 100% covered by tests.

By talking with many who advocate test-first principles, I find that they are also talking of a process where code and test writing are iterated. We are certainly doing it all the same way in reality, and it is the term ‘test-first’ that seems misleading to me.With experience, one can anticipate how to design the code as testable. I often write the code with a testable design first, then the associated tests, and then repeat.

Комментарии

Популярные сообщения из этого блога

A4tech. Мышь не найдена. Пожалуйста, подсоедините мышь.

Вывод в cmd или bat пустой строки.

Ускорение компиляции Visual Studio Solution методом "Copy Local = False".