September 2010
Intermediate to advanced
264 pages
5h 38m
English
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:
| tdd/test/DeckTest.cs | |
| | [TestFixture] |
| | public class DeckTest |
| | { |
| | [Test] |
| | 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 ...
Read now
Unlock full access