Unit Testing New Code vs. Existing Code
Testing the Greenfield code is far easier than testing the Brownfield code or legacy code. The main reason is that during the code of Brownfield application or legacy code we don’t consider about testability. So the class structure in the systems is often more tightly coupled than those codes that developed with tests. But it is not also true that “practicing test first development in Brownfield environment.” By following a great technique many developers find value. The technique is before fixing bug we create a test that fails. This fails test demonstrate that the bug is actually exists there. Then we fix the bug and run the test. The test passes. So our workflow becomes much simpler. Create a failing test; make the test pass. This workflow work well in Brownfield applications as it does in Greenfield application.