Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I feel you there, here are a couple of things I have found useful when writing unit tests to make them more solid:</p> <ul> <li>If you haven't already, try breaking down your unit tests to one assertion per test. You may have to do many assertions per unit of code that your testing if the methods are massive (this may mean your methods should be broken down too). But this will loosen up your unit tests and make them less prone to time consuming maintenance. Theres a good pattern to put into practice called <a href="http://c2.com/cgi-bin/wiki?ArrangeActAssert" rel="noreferrer">Arrange, Act Assert (AAA)</a></li> <li>Make sure your unit tests are completly isolated, i.e., there are no interactions or calls outside your code i.e., databases, web services etc.</li> <li>Use available frameworks to make your unit testing experience easier and to do most of the work for you, e.g., <a href="http://nbuilder.org/" rel="noreferrer">Nbuilder</a> to hack up lists of objects and <a href="http://code.google.com/p/moq/" rel="noreferrer">Moq</a> to mock out objects you need for testing.</li> <li>If you don't already, use <a href="http://en.wikipedia.org/wiki/Test_fixture" rel="noreferrer">test fixtures</a> so you dont have to set everything up for each test.</li> </ul> <p>TDD and unit testing is definitly something that starts off a real pain in the butt, but its one of those things that gets much easier and faster to do the more you keep at it.</p> <p><a href="http://richarddingwall.name/" rel="noreferrer">Richard Dingwall's blog</a> has quite a few articles on best practices for unit testing and TDD, many actually regarding unit testing with MVC.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload