Exception in OneTimeSetUp has no stack trace
See original GitHub issueWhen an exception is thrown in code called from a OneTimeSetUp method, I get:
Exception doesn’t have a stacktrace
Code to demonstrate the problem:
public class Tests
{
[OneTimeSetUp]
public void Setup()
{
throw new Exception("oops");
}
[Test]
public void Test1()
{
Assert.Pass();
}
}
Versions:
- .NET Core 3.0
- NUnit 3.12.0
- NUnit3TestAdapter 3.15.1
- Microsoft.NET.Test.SDK 16.3.0
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:25 (12 by maintainers)
Top Results From Across the Web
Unit Tests view - Cannot view stack trace of exception ...
When exception thrown from inside OneTimeSetup, Unit Tests view only shows a useless message: OneTimeSetUp: System.NotImplementedException : The method or ...
Read more >c# - Nunit test gives result OneTimeSetUp: No suitable ...
I have an issue where NUnit is telling me: "No suitable constructor was found". What causes this? I also get another message: "Exception ......
Read more >Developers - Exception in OneTimeSetUp has no stack trace -
When an exception is thrown in code called from a OneTimeSetUp method, I get: Exception doesn't have a stacktrace. Code to demonstrate the...
Read more >Stack trace not included in re-thrown exception
When re-throwing an exception, make sure to include the stack trace. Otherwise pertinent debug information is lost. Detector ID.
Read more >NotImplementedException Class (System)
The NotImplementedException exception indicates that the method or property that you are attempting to invoke has no implementation and therefore provides ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Please reconsider, this is HUGE waste of time. Think about CI scenario, sometimes setup is pretty complex and when it went wrong all you get is NullReferenceException.
FYI, you can sort-of bypass this issue, by wrapping all of your
OneTimeSetUpmethods in:Kinda sucks, but it’s better than what you get at the moment.