Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It's a slippery slope once you start initializing fields &amp; generally setting up the context of your test <em>within</em> the test method itself. This leads to large test methods and really really unmanageable fixtures that don't explain themselves very well.</p> <p>Instead, you should look at the BDD style naming &amp; test organization. Make one fixture per context, rather than one fixture per system-under-test. Then your [setup] truly does setup the context, and your tests can be simple one-liner asserts.</p> <p>It's much easier to read when you see a test output that does this:</p> <p>OrderFulfillmentServiceTests.cs</p> <ul> <li><p>with_an_order_from_a_new_customer</p> <ul> <li>it should check their credit from the credit service</li> <li>it should give no discount</li> </ul></li> <li><p>with valid credit check</p> <ul> <li>it should decrement inventory</li> <li>it should ship the goods</li> </ul></li> <li><p>with a customer in texas or california</p> <ul> <li>it should add appropriate sales tax</li> </ul></li> <li><p>with an order from a gold customer</p> <ul> <li>it should NOT check credit</li> <li>it should get expedited shipping added for free</li> </ul></li> </ul> <p>Our tests are now really good documentation for our system. Each "with_an..." is a test fixture, and the items below it are tests. Within those, you setup the context (the state of the world as the class name describes) and then the test does the simple assert that verifies what the method name says it does.</p>
    singulars
    1. This table or related slice is empty.
    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