How to programmatically force a test to fail? #3099
Unanswered
aradalvand
asked this question in
Q&A
Replies: 2 comments 7 replies
|
Sorry for the slow reply! To stop the test before its method runs and mark it as failed, call public ValueTask OnTestStart(TestContext context)
{
Fail.Test("arbitrary reason");
return ValueTask.CompletedTask;
}
One important detail: when this question was originally posted, TUnit accidentally swallowed exceptions thrown by |
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I've tried this:
But neither
AddLinkedCancellationToken(with a canceled token), norcontext.OverrideResultseem to have any effect whatsoever.What am I missing? Is there a way to programmatically short-circuit a test and have it fail immediately using its associated
TestContextinstance?All reactions