Skip to content

Commit 270d144

Browse files
authored
Update filter.md for NUnit (#14987)
1 parent f70bb54 commit 270d144

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

docs/filter.md

+47
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ supported by popular unit test frameworks.
2020
| -------------- | -------------------- |
2121
| MSTest | <ul><li>FullyQualifiedName</li><li>Name</li><li>ClassName</li><li>Priority</li><li>TestCategory</li></ul> |
2222
| Xunit | <ul><li>FullyQualifiedName</li><li>DisplayName</li><li>Traits</li></ul> |
23+
| NUnit | <ul><li>FullyQualifiedName</li><li>Name</li><li>Priority</li><li>TestCategory</li><li>Category</li><li>Property</li></ul>|
2324

2425
Allowed **operators**:
2526

@@ -145,3 +146,49 @@ In above code we defined traits with keys `Category` and `Priority` which can be
145146
| `dotnet test --filter "FullyQualifiedName~TestClass1\|Category=Nightly"` | Runs tests which have `TestClass1` in FullyQualifiedName **or** Category is Nightly. |
146147
| `dotnet test --filter "FullyQualifiedName~TestClass1&Category=Nightly"` | Runs tests which have `TestClass1` in FullyQualifiedName **and** Category is Nightly. |
147148
| `dotnet test --filter "(FullyQualifiedName~TestClass1&Category=Nightly)\|Priority=1"` | Runs tests which have either FullyQualifiedName contains `TestClass1` and Category is CategoryA or Priority is 1. |
149+
150+
### NUnit
151+
152+
```csharp
153+
namespace NUnitTestNamespace;
154+
155+
public class TestClass
156+
{
157+
[Property("Priority","1")]
158+
[Test]
159+
public void Test1()
160+
{
161+
Assert.Pass();
162+
}
163+
164+
[Property("Whatever", "SomeValue")]
165+
[Test]
166+
public void Test2()
167+
{
168+
Assert.Pass();
169+
}
170+
171+
[Category("SomeCategory")]
172+
[Test]
173+
public void Test3()
174+
{
175+
Assert.Pass();
176+
}
177+
}
178+
```
179+
180+
#### Usage of the filters
181+
182+
| Expression | What it does? |
183+
| ---------- | ------------- |
184+
| `dotnet test --filter FullyQualifiedName=NUnitTestNamespace.TestClass.Test1` | Runs only the given test |
185+
| `dotnet test --filter Name=Test1` | Runs all tests whose test name (method) equals `Test1`. |
186+
| `dotnet test --filter Name=TestClass` | Runs tests within all classes named `TestClass`. |
187+
| `dotnet test --filter Name=NUnitTestNamespace` | Runs all tests within the namespace `NUnitTestNamespace`. |
188+
| `dotnet test --filter Priority=1` | Runs tests with property named Priority and value = 1`. |
189+
| `dotnet test --filter Whatever=TestClass` | Runs tests with property named `Whatever` and value = `SomeValue`. |
190+
| `dotnet test --filter Category=SomeCategory` | Runs tests with category set to `SomeCategory`. Note: You can also use TestCategory in the filter. |
191+
192+
Logical operators works the same as for the other frameworks.
193+
194+

0 commit comments

Comments
 (0)