-
Notifications
You must be signed in to change notification settings - Fork 722
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proper test result exception message when hitting TimeoutAttribute
#3859
Comments
Hi @Prodigio How are you running the tests (VS, dotnet test, or the console runner), which framework are you targeting, and which versions of NUnit, NUnit3TestAdapter, and console runner are you using? Some initial skimming of the code could indicate that for dotnet core we don't set the message, but only set the label. Compare (framework flow)
against (dotnet core flow) nunit/src/NUnitFramework/framework/Internal/Commands/TimeoutCommand.cs Lines 110 to 113 in b34eba3
Also compare the difference in the tests nunit/src/NUnitFramework/tests/Attributes/TimeoutTests.cs Lines 297 to 299 in b34eba3
dotnet core version nunit/src/NUnitFramework/tests/Attributes/TimeoutTests.cs Lines 367 to 369 in b34eba3
I'm unsure if this difference is on purpose, but it looks like an mistake. Since we don't write anything in the message for dotnet core, the resulting XML does not contain any information and thus it cannot be presented for the user. On dotnet framework the test will have the following error message |
Hey @mikkelbu, sorry for the missing information. Here it is:
I do see the same message I'm not using the console. Other NUnit versions are:
I noticed, that besides NUnit we also have Thanks! |
Hi @Prodigio Thanks for all the information. I'm quite sure that the missing information is since you are targeting .NET Core 3.1 and we have made an mistake in #3190. That being said I don't think that we record stacktrace when the test fail due to a timeout, as we don't know how far in the code we are (so where exactly should the stacktrace point to). The two calls to But I think we should fix the .NET Core flow, so we also report |
Hi @mikkelbu,
This works fine in .net4.8, DeleteSource() is executed when the test times out. But it is not executed in .net6. I wonder if our issue is related to this one? Btw, I see #3190 is merged but we are still having that issue. Our versions:
Thank you! |
@lsokolova In .NET Framework, NUnit uses
In .NET48, the above test prints both However, if you change NET Core and later only uses cooperative |
Thank you for your answer @manfred-brands. |
@lsokolova I don't see any open issues about it. So I created one #4021 To make it work, the developer would not only have to re-write the tests but also the user code so that the
Adding this to |
Also running into this with .NET Core 3.1. No useful message shown with either |
I added this as part of #4025, but as that is stalled, I might need to separate the message fix from the cancellation part. |
That would be nice! I was considering removing the use of TimeoutAttribute from our test code and adding a unit test that checks via Reflection if it's used to prevent other developers from wasting their time on this. |
Temporary nuget package available from PR build artifacts |
Could we have a release with this fix, please? |
@manfred-brands Running "dotnet test" with the .NET 6 SDK and the latest versions of the |
#4118 has milestone 3.13.4, so this will be part of the next release, and this still have some outstanding items - https://github.com/nunit/nunit/milestone/42 - I guess some of them can be postponed. I think we have other bugs that also should be part of this milestone, but I don't have time to check it closely today. |
Hey guys,
lately I was expetimenting with the
TimeoutAttribute
and ran into a few timeouts for my tests. I only saw aException doesn't have a stacktrace
as a test result message, which confused me at first sight. Then I realized, the test were hitting the timeout.I tried to dig into the code to see, if implementing a timeout exception message is possible, but havn't found anything so far.
So I'd like to suggest a better test result message when hitting the timeout.
Code to reproduce:
Thanks and kind regards
The text was updated successfully, but these errors were encountered: