Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
swdev:dotnet:unit_testing_with_nunit [2016/06/30 15:36]
smayr [Run Tests]
swdev:dotnet:unit_testing_with_nunit [2016/06/30 15:38] (current)
smayr [Pattern AAA]
Line 66: Line 66:
 == Pattern AAA == == Pattern AAA ==
 Modern tests contain three parts: Modern tests contain three parts:
 +<code csharp>
 [TestMethod] [TestMethod]
 public void GetCount_ItemCountIsZero_NoNewMessages() public void GetCount_ItemCountIsZero_NoNewMessages()
Line 78: Line 79:
     Assert.AreEqual("No new messages.", result);     Assert.AreEqual("No new messages.", result);
 } }
 +</code>
    
 +This can be summed up as a pattern:
   * Arrange: setup everything needed for the running the tested code. This includes any initialization of dependencies, mocks and data needed for the test to run.   * Arrange: setup everything needed for the running the tested code. This includes any initialization of dependencies, mocks and data needed for the test to run.
   * Act: Invoke the code under test.   * Act: Invoke the code under test.
   * Assert: Specify the pass criteria for the test, which fails it if not met.   * Assert: Specify the pass criteria for the test, which fails it if not met.
 +
 +Source: [[http://www.typemock.com/unit-test-patterns-for-net|Unit Test Patterns for .NET]]