[Before(Test)] hooks don't report useful errors in VS (Code) or Rider
Is there a way to get more than this:
BeforeTest hook failed
at TUnit.Engine.Services.HookExecutor.ExecuteBeforeTestHooksAsync(AbstractExecutableTest test, CancellationToken cancellationToken)
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__DisplayClass10_0.<<ExecuteTestInternalAsync>b__0>d.MoveNext()
at TUnit.Engine.Services.TestExecution.TestCoordinator.<>c__DisplayClass10_0.<<ExecuteTestInternalAsync>b__0>d.MoveNext()
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)
Obviously just calling the method at the start of every test works in this case but [Before(class)] has the same issue and that's less straight forward.
It would be nice if the errors actually directly reported like they do in the tests themselves.
Pretty sure this is an IDE issue, as if you run via the command line you should see the inner exception
I ran this:
dotnet test Tests/Banking/BankingProviderTests/BankingProviderTests.csproj -- --treenode-filter "/*/BankingProviderTests/Transfers/TransfersTests/InternalToInternal_Succeeds"
This runs a single test.
This is what it gets:
Tests\Banking\BankingProviderTests\bin\Debug\net10.0\BankingProviderTests.dll : error run failed: Tests failed: Tests\Banking\BankingProviderTests\bin\Debug\net10.0\TestResults\BankingProviderTests_net10.0_x64.log' [net10.0|x64]
Test summary: total: 0, failed: 0, succeeded: 0, skipped: 0, duration: 0.3s
Which is even worse than what the IDE is reporting.
Your filter is wrong. It should only have 4 segments - You've got 5.
dotnet test Tests/Banking/BankingProviderTests/BankingProviderTests.csproj -- --treenode-filter "/*/*/TransfersTests/InternalToInternal_Succeeds"
OK, thanks. But why are all of the clients that consume this reporting junk instead of the proper error?
No idea!
It's odd to me that it works fine if I just call the function directly in the test, but doesn't work with the hook. Is there any way to work around whatever the limitation is?
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
This is still an issue with .NET 10 and Visual Studio 2026.
For reference, NUnit's [SetUp] feature correctly shows exceptions in the VS test output: