nunit-console
nunit-console copied to clipboard
System.ArgumentNullException with SetUpFixture in no namespace, and NUnit Framework 3.6.1
NuGet Packages used:
- NUnit 3.6.1
- NUnit.Console 3.11.1
Command line arguments:
...bunch of dll files.... --trace=Error --labels=On --timeout=30000 --noheader --framework=net-4.5 --result=C:\path\to\NUnitResults.xml;format=nunit2 --skipnontestassemblies --agents=4 --x86 --teamcity
After upgrade of NUnit.Console from 3.10.0 to 3.11.1 every console run ends with:
System.ArgumentNullException : Value cannot be null.
Parameter name: s
--ArgumentNullException
Value cannot be null.
Parameter name: s
at System.IO.StringReader..ctor(String s)
at System.Xml.XmlDocument.LoadXml(String xml)
at NUnit.Engine.TestEngineResult.get_XmlNodes()
at NUnit.Engine.Internal.ResultHelper.Merge(IList`1 results)
at NUnit.Engine.Runners.AggregatingTestRunner.RunTests(ITestEventListener listener, TestFilter filter)
at NUnit.Engine.Runners.AbstractTestRunner.Run(ITestEventListener listener, TestFilter filter)
at NUnit.Engine.Runners.MasterTestRunner.RunTests(ITestEventListener listener, TestFilter filter)
at NUnit.Engine.Runners.MasterTestRunner.Run(ITestEventListener listener, TestFilter filter)
at NUnit.ConsoleRunner.ConsoleRunner.RunTests(TestPackage package, TestFilter filter)
at NUnit.ConsoleRunner.ConsoleRunner.Execute()
at NUnit.ConsoleRunner.Program.Main(String[] args)
Do you have any clues what's wrong here? Tests are properly reported on CI server (TeamCity) but NUnit console ends with this exception and exit code -100.
Thanks
Hi,
Please can you run with trace=debug and add the log files? Thanks.
After deeper investigation I've found out that the issue was caused by presence of class file with class without namespace. It looked like:
using System;
using NUnit.Framework;
[SetUpFixture]
public class FixtureSetup
{
[OneTimeSetUp]
public void RunBeforeAnyTests()
{
Environment.CurrentDirectory = TestContext.CurrentContext.TestDirectory;
}
}
After change to
using System;
using NUnit.Framework;
namespace Corrent.Namespace.For.Tests
{
[SetUpFixture]
public class FixtureSetup
{
[OneTimeSetUp]
public void RunBeforeAnyTests()
{
Environment.CurrentDirectory = TestContext.CurrentContext.TestDirectory;
}
}
}
it runs fine now.
Thanks Pavel - this should work, so looks like you’ve found a bug. Are the results different if you upgrade the Nunit framework version?
@nunit/engine-team I’m away in holiday at the moment - if anyone’s got a chance to take a quick look at this, that’d be great. Sounds like it can’t be too complicated. If not - I’ll take a look when I’m back. 😊
I took a very quite look (too much real work at the moment). And the problem does not exists when using NUnit 3.8, so something has changed between 3.7.1 - still failing on this release - and 3.8. Looking at the release notes - https://github.com/nunit/nunit/releases/tag/3.8 - I cannot see an issue that exactly matches this, but my guess would be that https://github.com/nunit/nunit/issues/2361 also solved this issue. Currently, I don't have time to look at this in much more detail, but can you see if 3.8 (or better the hotfix 3.8.1) also works in your environment.
Hi, it will give it a try, for some reasons we still use NUnit 3.6.1 so I will upgrade that and rerun.
Thanks
Thanks Mikkel, really appreciate that! @pavel-spacil - How did it go? 🙂
Providing upgrading the framework resolves this issue, we should patch this up for the next release of the console, but upgrading the framework seems like a suitable workaround for this version. Pavel - would you have any interest in supplying a PR to fix this issue? We'd love the help! 😁
I've tried to run same code while using latest NUnit 3.12.0 and issue is gone.
@ChrisMaddock I may give it a try but NUnit sources always were a little bit mystery for me :)
Great! Glad we have a workaround.
If you do end up having a dig - let us know if we can help at all. 🙂