미분류

TDD

bemaru 2020. 5. 7. 16:41

 

TDD(Test Driven Development, 테스트 주도 개발)

테스트 주도 개발에서 작성되는 테스트는 단위 테스트가 대표적이다. 먼저 단위 테스트는 말 그대로 한 단위만^1^을 테스트하는 것이다. 단위 테스트를 작성하려면, 일단 테스트를 작성한 뒤 컴파일 에러가 일어나지 않도록 테스트에서 쓰이는 클래스와 그 메소드의 스텁을 만들어 둔다. 테스트가 실패하는 것을 확인하고(= 컴파일 에러는 없는 것을 확인하고) 클래스를 구현한다. 클래스에서 필요한 다른 클래스가 필요하면 일단 스텁으로 지금 작성중인 클래스의 테스트를 통과하게만 해 두고, 나중에 그 클래스의 테스트 케이스를 작성한 후 구현한다. 이런 식으로 프로젝트 전체를 완성해 나간다. 하지만 단위 테스트는 단위 하나하나에 대해서만 검증할 수 있으므로, 이를 해결하기 위해 인수 테스트를 작성한다. 사실 인수 테스트는 전통적으로 사람(QA)의 영역이었지만, 코드로도 약간 구현해두면 품질에 큰 도움이 된다^2^.

출차 : 소프트웨어 장인

 

 

Unit testing is a cornerstone of modern development. The benefits of unit testing for a project are pretty well understood: Unit testing decreases the number of bugs, reduces time to market and discourages overly coupled design. Those are all nice benefits, but there are further advantages more directly relevant to developers. When I write unit tests, I can have much greater confidence in the code. It’s easier to add features or fix bugs in tested code, because the unit tests act as a safety net while the code is changing.

출처 : Async Programming : Unit Testing Asynchronous Code

https://docs.microsoft.com/en-us/archive/msdn-magazine/2014/november/async-programming-unit-testing-asynchronous-code

 

반응형