You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/core/testing/unit-testing-with-dotnet-test.md
+13-7Lines changed: 13 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ title: Unit testing C# code in .NET Core using dotnet test and xUnit
3
3
description: Learn unit test concepts in C# and .NET Core through an interactive experience building a sample solution step-by-step using dotnet test and xUnit.
4
4
author: ardalis
5
5
ms.author: wiwagn
6
-
ms.date: 10/21/2020
6
+
ms.date: 08/02/2021
7
7
---
8
8
# Unit testing C# in .NET Core using dotnet test and xUnit
9
9
@@ -81,9 +81,10 @@ The following instructions provide the steps to create the test solution. See [C
81
81
* The preceding command:
82
82
* Creates the *PrimeService.Tests* project in the *PrimeService.Tests* directory. The test project uses [xUnit](https://xunit.net/) as the test library.
83
83
* Configures the test runner by adding the following `<PackageReference />`elements to the project file:
84
-
* "Microsoft.NET.Test.Sdk"
85
-
* "xunit"
86
-
* "xunit.runner.visualstudio"
84
+
*`Microsoft.NET.Test.Sdk`
85
+
*`xunit`
86
+
*`xunit.runner.visualstudio`
87
+
*`coverlet.collector`
87
88
88
89
* Add the test project to the solution file by running the following command:
89
90
@@ -167,7 +168,8 @@ Run `dotnet test`. The test passes.
167
168
168
169
### Add more tests
169
170
170
-
Add prime number tests for 0 and -1. You could copy the preceding test and change the following code to use 0 and -1:
171
+
Add prime number tests for 0 and -1. You could copy the test created in the preceding step and make copies of the following code to test 0 and -1.
172
+
But don't do it, as there's a better way.
171
173
172
174
```csharp
173
175
varprimeService=newPrimeService();
@@ -196,11 +198,15 @@ public void IsPrime_InputIs1_ReturnFalse()
Copy file name to clipboardExpand all lines: samples/snippets/core/testing/unit-testing-using-dotnet-test/csharp/PrimeService.Tests/PrimeService_IsPrimeShould.cs
0 commit comments