-
-
Notifications
You must be signed in to change notification settings - Fork 97
Closed
Description
Preamble
The current latest version (0.25.6) suffers from this, as does 0.22.31, but version 0.22.24 does not suffer from this.
It therefore seems to have been introduced with the 0.22.31 release.
I would assume that #2479 is the cause of this.
Reproduction
public class Foo
{
private void ThrowsArgumentException() => throw new ArgumentException("Just for testing");
[Test]
public async Task ThrowsAsync_DoesNotCheckType()
{
var exception = await Assert.ThrowsAsync<OverflowException>(LocalTestFunction);
await Assert.That(exception).IsNotNull();
await Assert.That(exception.Message).IsEqualTo("Just for testing");
await Assert.That(exception).IsTypeOf<OverflowException>();
return;
Task LocalTestFunction()
{
ThrowsArgumentException();
return Task.CompletedTask;
}
}
}Result with 0.22.24
AssertionException: Exception is of type ArgumentException instead of OverflowException for LocalTestFunction
Exception doesn't have a stacktrace
Result with 0.22.31 onwards (including 0.25.6)
AssertionException: Expected OverflowException but received ArgumentException
Exception doesn't have a stacktrace
Expectations
- I think it's fair to expect that
exceptionwill be of typeOverflowExceptionor the method fails.
This is an assertion after all, and I don't expectexceptionto actually beArgumentException! - As you can also see with version
0.22.31onwards, it's the custom assertion on type that is the one that fails.
When using generics, you expect that type, so this assertion shouldn't even have to be there, I guess. - Some documentation around
ThrowsAsync, as I couldn't find any on https://tunit.dev/docs
Or maybe my search skills are lacking, butexceptionandThrowsAsyncdon't find anything.
Because I figured my brain was fooling me at first, but only when I started digging, I saw the behavior I expected/thought was there all along.
Metadata
Metadata
Assignees
Labels
No labels