Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2478,6 +2478,7 @@ private static void GenerateReturnHandling(
private static void GenerateDependencies(CodeWriter writer, Compilation compilation, IMethodSymbol methodSymbol)
{
var dependsOnAttributes = methodSymbol.GetAttributes()
.Concat(methodSymbol.ContainingType.GetAttributes())
.Where(attr => attr.AttributeClass?.Name == "DependsOnAttribute" &&
attr.AttributeClass.ContainingNamespace?.ToDisplayString() == "TUnit.Core")
.ToList();
Expand Down
28 changes: 28 additions & 0 deletions TUnit.TestProject/DependsOnTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,31 @@ public static async Task AssertStartTimes()
await Assert.That(_test2Start).IsAfterOrEqualTo(_test1Start.AddSeconds(4.9));
}
}

public sealed class MyAsyncTest
{
public static int NumberOfInvocations = 0;

[Test]
public async Task Test()
{
NumberOfInvocations += 1;
await Assert.That(NumberOfInvocations).IsEqualTo(1);
}
}

[EngineTest(ExpectedResult.Pass)]
[DependsOn(typeof(MyAsyncTest), nameof(Test))]
public sealed class DependsOn_AsyncTest
{
[Test]
public async Task Test() => await Assert.That(MyAsyncTest.NumberOfInvocations).IsEqualTo(1);
}

[EngineTest(ExpectedResult.Pass)]
[DependsOn(typeof(MyAsyncTest), nameof(Test))]
public sealed class DependsOn_AsyncTest_Two
{
[Test]
public async Task Test() => await Assert.That(MyAsyncTest.NumberOfInvocations).IsEqualTo(1);
}
Loading