lundi 22 décembre 2014

Which methods should we unit test?

We're just about to start a new C# MVC project. We've spent some time reading up on unit testing and following some tutorials etc.


It's going to take a while to get our heads round, and we know that, however what's slightly unclear to us is how much of a codebase should be unit tested. If I think about our last MVC project we have:



  • Controllers

  • Extensions methods

  • Helper methods


To name but just a few. These also vary in degress of complexities - one extension method might trim a few characters from the end of a string, another might use some complex regular expressions to strip HTML from a string - I might think that the latter was worthy of testing whereas the earlier example wasn't complex enough to be tested, but that seems like a very wooly approach to testing.


Can anyone provide any guidance, or links to externals resources, where an approach to unit testing is documented. I've seen some blog posts that say test everything - other that say test the complicated methods etc. Id like to base our approach on a well tried and tested approach, if that even exists!


thanks in advance dotdev


Aucun commentaire:

Enregistrer un commentaire