-
|
I have an abstract test class defining a bunch of tests. In my case, my test class takes in an public abstract class ServiceInjectionTest(
IServiceCollection collection,
IEnumerable<IPartialServiceMatcher> allMatchers){...}
public IEnumerable<ServiceDescriptor> TransientServices() =>
GetMatchingDescriptors(MatchersWithLifetime(ServiceLifetime.Transient));
[Test]
[DisplayName("The service '$descriptor ServiceType' can be provided as transient.")]
[InstanceMethodDataSource(nameof(TransientServices))]
public async Task ServiceCanBeCreatedAsTransient(ServiceDescriptor descriptor) =>
await AssertServiceCanBeCreated(descriptor);However, I have a test class where there exists no transient services - so I get a TUnit error on runtime: ...
at TUnit.Core.ExecutableTest.InvokeTestAsync(Object instance, CancellationToken cancellationToken)
at TUnit.Engine.TestExecutor.ExecuteTestAsync(AbstractExecutableTest executableTest, CancellationToken cancellationToken)
at TUnit.Engine.Helpers.TimeoutHelper.ExecuteWithTimeoutAsync(Func`2 taskFactory, Nullable`1 timeout, CancellationToken cancellationToken, String timeoutMessage)
at TUnit.Engine.TestExecutor.ExecuteAsync(AbstractExecutableTest executableTest, CancellationToken cancellationToken)
at TUnit.Engine.TestExecutor.ExecuteAsync(AbstractExecutableTest executableTest, CancellationToken cancellationToken)
at TUnit.Engine.TestExecutor.ExecuteAsync(AbstractExecutableTest executableTest, CancellationToken cancellationToken)
at TUnit.Engine.Services.TestExecution.TestCoordinator.<>c__DisplayClass11_0.<<ExecuteTestInternalAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at TUnit.Engine.Services.TestExecution.TestCoordinator.<>c__DisplayClass11_0.<<ExecuteTestInternalAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at TUnit.Engine.Services.TestExecution.RetryHelper.ExecuteWithRetry(TestContext testContext, Func`1 action)
at TUnit.Engine.Services.TestExecution.RetryHelper.ExecuteWithRetry(TestContext testContext, Func`1 action)
at TUnit.Engine.Services.TestExecution.TestCoordinator.ExecuteTestInternalAsync(AbstractExecutableTest test, CancellationToken cancellationToken)Is there a way to create a custom annotation ala |
Beta Was this translation helpful? Give feedback.
Answered by
thomhurst
Oct 25, 2025
Replies: 1 comment 1 reply
-
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
TheRumle
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
#3520