Recently, I start realize the benefits of TDD, it really could give me a chance to think about how others people gonna use my API, how should I design it.
So normally, Create a falling test case first(Simulate how user will use the API), then start implement the method to make the test case pass(keep things as simple as possible), after that, refactor the method, improve the internal implementation without changing the external behavior.
Principle:
- One logical assertion per test.
- Keep test code maintainable and Don’t repeat yourself.
- Test could be independent, could run in any order.
Assembly | Unit Test Assembly |
Namespace | Namespace_Test Folder |
Class | Class_Test Folder |
Behavior… | Test Class… |