Skip to content

Commit cd1f6c2

Browse files
committed
Add TUnit dependency ordering example and update solution creation links in C# and VB documentation
1 parent 7277b01 commit cd1f6c2

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

docs/core/testing/order-unit-tests.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,29 @@ To order tests explicitly, NUnit provides an [`OrderAttribute`](https://docs.nun
9999

100100
TUnit provides a `[DependsOn]` attribute to control test execution order through explicit dependencies. When a test depends on another, TUnit ensures the prerequisite test completes before executing the dependent test. This approach allows you to maintain test parallelism for independent tests while enforcing order where necessary.
101101

102-
:::code language="csharp" source="snippets/order-unit-tests/csharp/TUnit.TestProject/ByDependency.cs":::
102+
```csharp
103+
using TUnit.Core;
104+
105+
namespace OrderUnitTests.TUnit;
106+
107+
public class DependencyOrderedTests
108+
{
109+
[Test]
110+
public async Task FirstTest()
111+
{
112+
// This test runs first
113+
await Task.CompletedTask;
114+
}
115+
116+
[Test]
117+
[DependsOn(nameof(FirstTest))]
118+
public async Task SecondTest()
119+
{
120+
// This test runs after FirstTest completes
121+
await Task.CompletedTask;
122+
}
123+
}
124+
```
103125

104126
### Behavior
105127

docs/core/testing/unit-testing-csharp-with-tunit.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ In this section, a solution is created that contains the source and test project
2929
PrimeServiceTests.csproj
3030
```
3131

32-
The following instructions provide the steps to create the test solution. See [Commands to create test solution](#create-test-cmd) for instructions to create the test solution in one step.
32+
The following instructions provide the steps to create the test solution. See [Commands to create test solution](#commands-to-create-the-solution) for instructions to create the test solution in one step.
3333

3434
* Open a shell window.
3535
* Run the following command:

docs/core/testing/unit-testing-visual-basic-with-tunit.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ In this section, a solution is created that contains the source and test project
2929
PrimeServiceTests.vbproj
3030
```
3131

32-
The following instructions provide the steps to create the test solution. See [Commands to create test solution](#create-test-cmd) for instructions to create the test solution in one step.
32+
The following instructions provide the steps to create the test solution. See [Commands to create test solution](#commands-to-create-the-solution) for instructions to create the test solution in one step.
3333

3434
* Open a shell window.
3535
* Run the following command:

0 commit comments

Comments
 (0)