0

I came to know that in some shops, code is developed first, given to QA for testing and then developers write unit tests for that code. Is this approach acceptable ? If yes, then what are the pros & cons ?

I got some clues in answers in an unrelated question : Is Unit Testing worth the effort? But, I also need answers specifically for my question.

MasterJoe
  • 2,103
  • 5
  • 32
  • 58
  • QA *isn't* done until after you have created and run the unit tests. The *necessary* unit tests. I would agree that it is can be overdone. – user207421 May 18 '17 at 01:26

1 Answers1

1

A lot of serious dev "shops" do this.

When you develop complex applications for a client you never actually "care" about simple unit tests, the ones you can write any day of the coding project. You have to "test at a coarser level of granularity" (32:30 in the video) and you generally want to test things that are not supposed to change so you don't write tests over and over again, when the architecture changes a bit.

To answer your question: creating unit tests at the end is a fail safe for later, when you fix bugs making sure they don't break existing client required functionality. Writing tests at the end also gives you the insight you need to write them, the client's wishes are known and not subject to change any more.

Bottom line: It's not a science, you only get good at it while doing it.

PS: Not a fan, but this one is "right on the money" https://www.youtube.com/watch?v=9LfmrkyP81M

unom
  • 11,438
  • 4
  • 34
  • 54