nunit: NullReferenceException when using either --inprocess or --domain=Multiple options
Due to a problem in project set-up (it appears so) I receive NullReferenceException when running unit test with following stack trace:
Test Run Summary
Overall result: System.NullReferenceException: Object reference not set to an instance of an object.
at NUnit.Common.ColorConsoleWriter.WriteLabel(String label, Object option, ColorStyle valueStyle)
at NUnit.Common.ColorConsoleWriter.WriteLabelLine(String label, Object option, ColorStyle valueStyle)
at NUnit.ConsoleRunner.ResultReporter.WriteSummaryReport()
at NUnit.ConsoleRunner.ConsoleRunner.RunTests(TestPackage package, TestFilter filter)
at NUnit.ConsoleRunner.Program.Main(String[] args)
No other evidence of the problem are there in report or console. When attached with VS to the nunit process I’ve managed to discover that the report is the following:
<test-run id="2" testcasecount="0" engine-version="3.4.1.0" clr-version="4.0.30319.42000" start-time="2016-08-10 12:48:48Z" end-time="2016-08-10 12:48:48Z" duration="0.049014">
<command-line><![CDATA["F:\Projects\[censored]\./packages/NUnit.ConsoleRunner.3.4.1/tools/nunit3-console.exe" F:\Projects\[censored]\UnitTests.nunit]]></command-line>
<test-suite type="Project" id="2" name="UnitTests.nunit" fullname="F:\Projects\[censored]\UnitTests.nunit" testcasecount="0" />
</test-run>
It appears NullReferenceException happens because ResultReporter relies on the fact that “result” property exists in test run which is not true:
public ResultReporter(XmlNode result, ExtendedTextWriter writer, ConsoleOptions options)
{
_result = result;
_writer = writer;
_overallResult = result.GetAttribute("result");
if (_overallResult == "Skipped")
_overallResult = "Warning";
_options = options;
Summary = new ResultSummary(result);
}
Could we improve logging in this case?
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 20 (16 by maintainers)
I’m trying to figure out this right now. At the current moment it seems like if I have more then one test assembly in then project - it fails. Probably it’s wrong - I did not finish yet