Skip to content
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

Missing output with failed test stack traces for Assert.Multiple #907

Closed
gps7 opened this issue Jun 30, 2022 · 7 comments · Fixed by #908
Closed

Missing output with failed test stack traces for Assert.Multiple #907

gps7 opened this issue Jun 30, 2022 · 7 comments · Fixed by #908
Assignees
Labels
Bug Something isn't working as expected. High Priority High priority issue
Milestone

Comments

@gps7
Copy link

gps7 commented Jun 30, 2022

Hi,
I am missing test output with stack traces for failed tests if Assert.Multiple is used. For running example test fails but output not showing all required information about failures inside of Multiple assert scope but only single stack trace to the test itself:

[Test]
public void AssertMultiple()
{
Assert.Multiple(() =>
{
ValidateInteger();
Assert.That("a", Is.EqualTo("b"), "String");
ValidateInteger();
});
}

private void ValidateInteger() => Assert.That(1, Is.EqualTo(2), "Integer");
Running Nunit console with fallowing command line provides empty TEST_OUTPUT.log file:
"nunit3-console.exe" MyTests.dll --test=MyTests.TestClass.AssertMultiple --out=TEST_OUTPUT.log

I've expect to see not single stack trace but 3 stack traces for 3 failures in single Assert.Multiple request which leads to failed assert. I've already checked the Nunit-console application and it provides all this information correctly.

176107084-f1899f00-4591-469d-9b53-c12273a8bbf2

I am using Framework 4.8 with TestCentric 2.0.0-alpha4 version.

This is a fallow up issue after creating issue #4129 nunit/nunit#4129 at Nunit and issue #1192 nunit/nunit-console#1192 at Nunit-Console. Please refer to the lined items for more details if needed.

@CharliePoole CharliePoole added Bug Something isn't working as expected. High Priority High priority issue labels Jul 1, 2022
@CharliePoole CharliePoole added this to the 2.0.0 milestone Jul 1, 2022
@CharliePoole
Copy link
Contributor

I'm confirming this by code inspection. The GUI uses the historic Errors and Failures display, which was part of the old NUnit V2 GUI. At that time, there was no such thing as multiple asserts, warnings, etc. So, like other third-party runners for NUnit tests, it cannot handle the newer features.

This is a big deal both in priority and difficulty to fix. As an illustration, the ResultNode class, which is used to represent test results, doesn't even have fields for multiple messages and stack traces. I've made it a 2.0 issue because I think the fix would be too difficult in the 1.x environment and we are already up to alpha 6 in the 2.0 releases.

I'll need to plan a series of small changes to build up to this, while maintaining compatibility with older versions of NUnit, so hang on while I think about it. :-)

@CharliePoole
Copy link
Contributor

CharliePoole commented Jul 1, 2022

Steps:

  • Update Result.Node to include collection of Assertion records, the "new" way of tracking test results.
  • Add a test with Assert.Multiple and multiple failures to mock-assembly.dll for use in testing the UI.
  • Populate Errors and Failures list control using assertions
  • Populate Errors and Failures StackTrace using assertions

@CharliePoole
Copy link
Contributor

@gps7 Based on my experiments, I think you should be able to see the correct results by selecting the failing test in the tree and using the Test Properties tab. This remains an issue, however, because that tab doesn't give access to the source code based display of the stack.

I have given some thought about eliminating the Errors and Failures tab, but I can't figure out a way to integrate everything into the Properties tab. For now, I'd like to get Errors and Failures working properly.

@CharliePoole
Copy link
Contributor

For now, I'm keeping the existing UI. The list of failed tests will become a list of failed assertions so that a test with 3 failures will have 3 entries in the list. I think this is simpler than having the user first select the test, then select the assertion.

@CharliePoole
Copy link
Contributor

CharliePoole commented Jul 2, 2022

Surprisingly, this was easier than I though. So far I have avoided delving into the internals of the stack display control. The fix is available from the myget feed as version 2.0.0-dev00165

@CharliePoole CharliePoole modified the milestones: 2.0.0, 2.0.0-next Jul 2, 2022
@gps7
Copy link
Author

gps7 commented Jul 4, 2022

@CharliePoole thanks for fixing, Glad to hear that it was easier than originally thought.

@CharliePoole
Copy link
Contributor

🎉 This issue has been resolved in version 2.0.0-alpha7 🎉

The release is available on:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working as expected. High Priority High priority issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants