Enter the Unit Test

Unit tests are small, method-level tests developers write every time they make a change to the software to prove the changes they made work as expected.

For example, say we wanted to verify our deck of cards had fifty-two cards in it (and not fifty-three). We could write a unit test that would look something like this:

public class DeckTest
public ​void​ Verify_deck_contains_52_cards()
var deck = new Deck();
Assert.AreEqual(52, deck.Count());

Just to be clear, the previous code isn’t the actual code we run as part of our Black Jack simulator in production. This is test code that verifies our real code works as expected.

Whenever we have a doubt about how ...

Get The Agile Samurai now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.