The following LINQPad query throws NullReferenceException
in the try-catch block:
void Main()
{
var specialFolder = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
var workingFolder = $@"{specialFolder}\NUnitLiteTestResults";
var args = new[]
{
"--labels=All",
"--nocolor",
"--noheader",
$"--work={workingFolder}"
};
try
{
(new AutoRun()).Execute(args);
}
catch (NullReferenceException ex)
{
ex.Dump("why?");
}
}
public class Runner
{
/*
public static int Main(string[] args) {
return new AutoRun(Assembly.GetCallingAssembly()).Execute(new String[] {"--labels=All"});
}
*/
[TestFixture]
public class FooTest
{
[Test]
public void ShouldCheckBoolean()
{
Assert.IsTrue(true);
}
[Test]
public void ShouldCompareNumbers()
{
Assert.AreEqual(2, 2);
}
[Test]
public void ShouldCompareStrings()
{
Assert.AreEqual("abc", "abc");
}
[Test]
public void TestCompareLists()
{
Assert.AreEqual(new int[] { 1, 2, 3 }, new int[] { 1, 2, 3 });
}
}
}
Am I missing any setup code here?
Exception (there is no C:\src\nunit
folder on my machine):
Object reference not set to an instance of an object.
at System.IO.TextWriter.Dispose()
at System.IO.TextWriter.Dispose()
at System.IO.TextWriter.SyncTextWriter.Dispose(Boolean disposing)
at System.IO.TextWriter.Dispose()
at NUnit.Common.ExtendedTextWrapper.Dispose(Boolean disposing) in C:\src\nunit\nunit\src\NUnitFramework\nunitlite\ExtendedTextWrapper.cs:line 83
at System.IO.TextWriter.Dispose()
at NUnitLite.TextRunner.Execute(String[] args) in C:\src\nunit\nunit\src\NUnitFramework\nunitlite\TextRunner.cs:line 149
at NUnitLite.AutoRun.Execute(String[] args) in C:\src\nunit\nunit\src\NUnitFramework\nunitlite\AutoRun.cs:line 82
at UserQuery.Main()
NUnitLite
NuGet package via LINQPad. – Karolynkaron