Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
swdev:dotnet:unit_testing_with_nunit [2015/08/07 10:19] smayr [Usage] |
swdev:dotnet:unit_testing_with_nunit [2016/06/30 15:38] (current) smayr [Pattern AAA] |
||
---|---|---|---|
Line 63: | Line 63: | ||
* Run Test Runner, and create new Test project (File > New Project). | * Run Test Runner, and create new Test project (File > New Project). | ||
* Select assembly or application containing unit tests (Project > Add Assembly). Note: These assemblies and applications must have a reference to '' | * Select assembly or application containing unit tests (Project > Add Assembly). Note: These assemblies and applications must have a reference to '' | ||
+ | |||
+ | == Pattern AAA == | ||
+ | Modern tests contain three parts: | ||
+ | <code csharp> | ||
+ | [TestMethod] | ||
+ | public void GetCount_ItemCountIsZero_NoNewMessages() | ||
+ | { | ||
+ | //Arrange | ||
+ | Mailbox mailbox = new Mailbox(); | ||
+ | | ||
+ | //Act | ||
+ | var result = mailbox.GetCount(0); | ||
+ | | ||
+ | //Assert | ||
+ | Assert.AreEqual(" | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | This can be summed up as a pattern: | ||
+ | * Arrange: setup everything needed for the running the tested code. This includes any initialization of dependencies, | ||
+ | * Act: Invoke the code under test. | ||
+ | * Assert: Specify the pass criteria for the test, which fails it if not met. | ||
+ | |||
+ | Source: [[http:// |