-
-
Notifications
You must be signed in to change notification settings - Fork 135
Expand file tree
/
Copy pathTestMethodInvoker.cs
More file actions
22 lines (19 loc) · 787 Bytes
/
Copy pathTestMethodInvoker.cs
File metadata and controls
22 lines (19 loc) · 787 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
using TUnit.Core;
namespace TUnit.Engine.Services.TestExecution;
/// <summary>
/// Invokes the actual test method with proper instance handling.
/// Single Responsibility: Test method invocation.
/// </summary>
internal sealed class TestMethodInvoker
{
public Task InvokeTestAsync(AbstractExecutableTest test, CancellationToken cancellationToken)
{
if (test.Context.InternalDiscoveredTest?.TestExecutor is { } testExecutor)
{
return testExecutor.ExecuteTest(test.Context,
() => new ValueTask(test.InvokeTestAsync(test.Context.Metadata.TestDetails.ClassInstance, cancellationToken)))
.AsTask();
}
return test.InvokeTestAsync(test.Context.Metadata.TestDetails.ClassInstance, cancellationToken);
}
}