I have this javascript project which has a unit test suite(about 200unit tests) that covers about 11.31% of the code that it was testing. The project has evolved greatly but the unit tests where never updated since. Now, I have two options:

  1. Spend some time to update the existing unit tests and then write new unit tests for the rest of the code.
  2. Rewrite Unit Tests for the entire project from scratch.

Also, only about 10% of those initial unit tests pass now.



1 Answer 1


Testing code is still code, intended to accomplish some function. That it's a "back room" or "back stage" function is just a detail.

Now, you have a codebase with 200 functions, that minimally accomplishes the coverage you need, and only 10% works. If this were a user-facing codebase, you'd probably conclude it wasn't worth updating as-is, where-is. That a clean slate--perhaps using more up-to-date tooling, or with new test cases more eagerly and completely covering what the module has become--would be the right way to go.

You might not need to "throw away" everything. 10% of the tests still pass, so you might start with those and cull the rest. Or at least scan and learn from existing tests (both working and possibly ones that aren't working, but might be close). My experience suggests you might find this "learning from, and occasionally copying from" the old test base accelerates your new test development. But with such a low-coverage, low-passing test base, starting with it seems more trouble and difficulty than it's worth.

Not the answer you're looking for? Browse other questions tagged or ask your own question.