Is it recommended to write unit test before coding



  • I know that it is recommended to write unit test before coding. But my question is related to test cases. When should I write test cases? When I already have written code or before it.



  • Typically, you can do testing at any point in the development cycle; therefore you can write test cases at any point. If you have requirements to build from, you have the building blocks for test cases in the future. If you have code, you can write test cases while the code is being built. If you already have the code, you can write tests too. Do you have data? You can write test cases. Do you have configurations? You can write test cases. As per your request, "when should I write test cases?". It depends. It depends on: your project? what your role in the project is? who's testing? when does it need to be tested by? regulated environment? target installation environment? etc, etc. At the end of the day, you need to take a look at your own risks and apply your own heuristics as to when your write test cases.


Log in to reply
 

Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2