From ddc4ba94a305a8d4afd73d62e3379745c1a72b59 Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Thu, 12 Apr 2012 15:32:55 +0100 Subject: [PATCH] Specify /noxml in the NUnit-Console command line if xml test results are not to be generated. --- .../Testing/CodeCoverageTestRunnerTests.cs | 4 +-- .../Test/Testing/PartCoverApplicationTests.cs | 4 +-- ...mandLine.cs => NUnitConsoleApplication.cs} | 10 ++++++- .../NUnitConsoleCommandLineTests.cs | 29 +++++++++++++++++++ ...NUnitConsoleProcessStartInfoTestFixture.cs | 2 +- .../Tree/RunNUnitTestsForMethodTestFixture.cs | 2 +- .../RunNUnitTestsWithDebuggerTestFixture.cs | 4 +-- .../Tree/RunTestInPadCommandTestFixture.cs | 2 +- .../RunTestWithDebuggerCommandTestFixture.cs | 4 +-- .../Analysis/UnitTesting/UnitTesting.csproj | 2 +- 10 files changed, 50 insertions(+), 13 deletions(-) rename src/AddIns/Analysis/UnitTesting/Src/{NUnitConsoleCommandLine.cs => NUnitConsoleApplication.cs} (96%) diff --git a/src/AddIns/Analysis/CodeCoverage/Test/Testing/CodeCoverageTestRunnerTests.cs b/src/AddIns/Analysis/CodeCoverage/Test/Testing/CodeCoverageTestRunnerTests.cs index 416c25431c..a0f2da9c78 100644 --- a/src/AddIns/Analysis/CodeCoverage/Test/Testing/CodeCoverageTestRunnerTests.cs +++ b/src/AddIns/Analysis/CodeCoverage/Test/Testing/CodeCoverageTestRunnerTests.cs @@ -118,7 +118,7 @@ namespace ICSharpCode.CodeCoverage.Tests.Testing string expectedCommandLine = "--target \"d:\\sharpdevelop\\bin\\Tools\\NUnit\\nunit-console-x86.exe\" " + "--target-work-dir \"c:\\projects\\MyTests\\bin\\Debug\" " + - "--target-args \"\\\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\\\" /results=\\\"d:\\temp\\results.txt\\\"\" " + + "--target-args \"\\\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\\\" /noxml /results=\\\"d:\\temp\\results.txt\\\"\" " + "--output \"c:\\projects\\MyTests\\PartCover\\coverage.xml\" " + "--include [MyTests]*"; @@ -218,7 +218,7 @@ namespace ICSharpCode.CodeCoverage.Tests.Testing "\"d:\\sharpdevelop\\bin\\Tools\\PartCover\\PartCover.exe\" " + "--target \"d:\\sharpdevelop\\bin\\Tools\\NUnit\\nunit-console-x86.exe\" " + "--target-work-dir \"c:\\projects\\MyTests\\bin\\Debug\" " + - "--target-args \"\\\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\\\"\" " + + "--target-args \"\\\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\\\" /noxml\" " + "--output \"c:\\projects\\MyTests\\PartCover\\coverage.xml\" " + "--include [*]*"; } diff --git a/src/AddIns/Analysis/CodeCoverage/Test/Testing/PartCoverApplicationTests.cs b/src/AddIns/Analysis/CodeCoverage/Test/Testing/PartCoverApplicationTests.cs index b4e2ecdc85..1f4c628ef4 100644 --- a/src/AddIns/Analysis/CodeCoverage/Test/Testing/PartCoverApplicationTests.cs +++ b/src/AddIns/Analysis/CodeCoverage/Test/Testing/PartCoverApplicationTests.cs @@ -133,7 +133,7 @@ namespace ICSharpCode.CodeCoverage.Tests.Testing string expectedCommandLine = "--target \"d:\\sharpdevelop\\bin\\Tools\\NUnit\\nunit-console-x86.exe\" " + "--target-work-dir \"c:\\projects\\MyTests\\bin\\Debug\" " + - "--target-args \"\\\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\\\"\" " + + "--target-args \"\\\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\\\" /noxml\" " + "--output \"c:\\projects\\MyTests\\PartCover\\coverage.xml\" " + "--include [*]*"; @@ -157,7 +157,7 @@ namespace ICSharpCode.CodeCoverage.Tests.Testing string expectedCommandLine = "--target \"d:\\sharpdevelop\\bin\\Tools\\NUnit\\nunit-console-x86.exe\" " + "--target-work-dir \"c:\\projects\\MyTests\\bin\\Debug\" " + - "--target-args \"\\\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\\\"\" " + + "--target-args \"\\\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\\\" /noxml\" " + "--output \"c:\\projects\\MyTests\\PartCover\\coverage.xml\" " + "--include [MyTests]* " + "--include [MoreTests]* " + diff --git a/src/AddIns/Analysis/UnitTesting/Src/NUnitConsoleCommandLine.cs b/src/AddIns/Analysis/UnitTesting/Src/NUnitConsoleApplication.cs similarity index 96% rename from src/AddIns/Analysis/UnitTesting/Src/NUnitConsoleCommandLine.cs rename to src/AddIns/Analysis/UnitTesting/Src/NUnitConsoleApplication.cs index f6ff76fb75..5eb4586197 100644 --- a/src/AddIns/Analysis/UnitTesting/Src/NUnitConsoleCommandLine.cs +++ b/src/AddIns/Analysis/UnitTesting/Src/NUnitConsoleApplication.cs @@ -51,6 +51,7 @@ namespace ICSharpCode.UnitTesting NoDots = options.NoDots; Labels = options.Labels; ShadowCopy = !options.NoShadow; + NoXmlOutputFile = !options.CreateXmlOutputFile; if (options.CreateXmlOutputFile) { GenerateXmlOutputFileName(); @@ -121,6 +122,11 @@ namespace ICSharpCode.UnitTesting /// public string XmlOutputFile; + /// + /// Use /noxml. + /// + public bool NoXmlOutputFile = true; + /// /// Fixture to test. Null = test all fixtures. /// @@ -195,7 +201,9 @@ namespace ICSharpCode.UnitTesting b.Append(" /labels"); if (NoDots) b.Append(" /nodots"); - if (XmlOutputFile != null) { + if (NoXmlOutputFile) { + b.Append(" /noxml"); + } else if (XmlOutputFile != null) { b.Append(" /xml=\""); b.Append(XmlOutputFile); b.Append('"'); diff --git a/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitConsoleCommandLineTests.cs b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitConsoleCommandLineTests.cs index cfebc1c133..93f237a0bd 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitConsoleCommandLineTests.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitConsoleCommandLineTests.cs @@ -32,6 +32,7 @@ namespace UnitTesting.Tests.Frameworks NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests); app.NoLogo = false; app.ShadowCopy = true; + app.NoXmlOutputFile = false; app.Results = @"C:\results.txt"; string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /results=\"C:\\results.txt\""; @@ -45,6 +46,7 @@ namespace UnitTesting.Tests.Frameworks NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests); app.NoLogo = true; app.ShadowCopy = true; + app.NoXmlOutputFile = false; string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /nologo"; Assert.AreEqual(expectedCommandLine, app.GetArguments()); @@ -57,6 +59,7 @@ namespace UnitTesting.Tests.Frameworks NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests); app.NoLogo = false; app.ShadowCopy = false; + app.NoXmlOutputFile = false; string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /noshadow"; Assert.AreEqual(expectedCommandLine, app.GetArguments()); @@ -70,6 +73,7 @@ namespace UnitTesting.Tests.Frameworks app.NoLogo = false; app.ShadowCopy = true; app.NoThread = true; + app.NoXmlOutputFile = false; string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /nothread"; Assert.AreEqual(expectedCommandLine, app.GetArguments()); @@ -83,6 +87,7 @@ namespace UnitTesting.Tests.Frameworks app.NoLogo = false; app.ShadowCopy = true; app.NoDots = true; + app.NoXmlOutputFile = false; string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /nodots"; Assert.AreEqual(expectedCommandLine, app.GetArguments()); @@ -96,6 +101,7 @@ namespace UnitTesting.Tests.Frameworks app.NoLogo = false; app.ShadowCopy = true; app.Labels = true; + app.NoXmlOutputFile = false; string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /labels"; Assert.AreEqual(expectedCommandLine, app.GetArguments()); @@ -109,6 +115,7 @@ namespace UnitTesting.Tests.Frameworks app.NoLogo = false; app.ShadowCopy = true; app.Fixture = "TestFixture"; + app.NoXmlOutputFile = false; string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /run=\"TestFixture\""; Assert.AreEqual(expectedCommandLine, app.GetArguments()); @@ -122,6 +129,7 @@ namespace UnitTesting.Tests.Frameworks app.NoLogo = false; app.ShadowCopy = true; app.NamespaceFilter = "TestFixture"; + app.NoXmlOutputFile = false; string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /run=\"TestFixture\""; Assert.AreEqual(expectedCommandLine, app.GetArguments()); @@ -135,11 +143,26 @@ namespace UnitTesting.Tests.Frameworks app.NoLogo = false; app.ShadowCopy = true; app.XmlOutputFile = @"C:\NUnit.xml"; + app.NoXmlOutputFile = false; string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /xml=\"C:\\NUnit.xml\""; Assert.AreEqual(expectedCommandLine, app.GetArguments()); } + [Test] + public void NoXmlWhenXmlOutputFileSpecified() + { + SelectedTests selectedTests = new SelectedTests(project); + NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests); + app.NoLogo = false; + app.ShadowCopy = true; + app.XmlOutputFile = @"C:\NUnit.xml"; + app.NoXmlOutputFile = true; + + string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /noxml"; + Assert.AreEqual(expectedCommandLine, app.GetArguments()); + } + [Test] public void TestMethod() { @@ -149,6 +172,7 @@ namespace UnitTesting.Tests.Frameworks app.ShadowCopy = true; app.Fixture = "TestFixture"; app.Test = "Test"; + app.NoXmlOutputFile = false; string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /run=\"TestFixture.Test\""; Assert.AreEqual(expectedCommandLine, app.GetArguments()); @@ -163,6 +187,7 @@ namespace UnitTesting.Tests.Frameworks NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests); app.NoLogo = false; app.ShadowCopy = true; + app.NoXmlOutputFile = false; string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /run=\"TestFixture.Test\""; Assert.AreEqual(expectedCommandLine, app.GetArguments()); @@ -175,6 +200,7 @@ namespace UnitTesting.Tests.Frameworks NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests); app.NoLogo = false; app.ShadowCopy = true; + app.NoXmlOutputFile = false; string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /run=\"Project.MyTests\""; Assert.AreEqual(expectedCommandLine, app.GetArguments()); @@ -187,6 +213,7 @@ namespace UnitTesting.Tests.Frameworks NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests); app.NoLogo = true; app.ShadowCopy = true; + app.NoXmlOutputFile = false; FileUtility.ApplicationRootPath = @"C:\SharpDevelop"; @@ -211,6 +238,7 @@ namespace UnitTesting.Tests.Frameworks app.NoLogo = false; app.ShadowCopy = true; app.Results = @"C:\results.txt"; + app.NoXmlOutputFile = false; string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" " + @@ -235,6 +263,7 @@ namespace UnitTesting.Tests.Frameworks NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests); app.NoLogo = false; app.ShadowCopy = true; + app.NoXmlOutputFile = false; string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" " + "/run=\"MyTests.TestFixture+InnerTest\""; diff --git a/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitConsoleProcessStartInfoTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitConsoleProcessStartInfoTestFixture.cs index a63fad5c3a..8902702f73 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitConsoleProcessStartInfoTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitConsoleProcessStartInfoTestFixture.cs @@ -50,7 +50,7 @@ namespace UnitTesting.Tests.Frameworks public void CommandLineArgumentsAreNUnitConsoleExeCommandLineArguments() { string expectedCommandLine = - "\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\""; + "\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\" /noxml"; Assert.AreEqual(expectedCommandLine, info.Arguments); } diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/RunNUnitTestsForMethodTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunNUnitTestsForMethodTestFixture.cs index a8edcd6ccf..d604124e99 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Tree/RunNUnitTestsForMethodTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunNUnitTestsForMethodTestFixture.cs @@ -173,7 +173,7 @@ namespace UnitTesting.Tests.Tree StartNUnitTestRunner(); string expectedArgs = - "\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\" " + + "\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\" /noxml " + "/results=\"c:\\temp\\tmp66.tmp\" " + "/run=\"MyTests.MyTestClass.MyTestMethod\""; Assert.AreEqual(expectedArgs, context.MockProcessRunner.CommandArgumentsPassedToStartMethod); diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/RunNUnitTestsWithDebuggerTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunNUnitTestsWithDebuggerTestFixture.cs index 19ccf38875..2bea660cd7 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Tree/RunNUnitTestsWithDebuggerTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunNUnitTestsWithDebuggerTestFixture.cs @@ -57,7 +57,7 @@ namespace UnitTesting.Tests.Tree StartTestDebugger(); string expectedArguments = "\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\" " + - "/noshadow " + + "/noshadow /noxml " + "/results=\"c:\\temp\\tmp66.tmp\" " + "/run=\"MyTests.MyTestClass.MyTestMethod\""; @@ -167,7 +167,7 @@ namespace UnitTesting.Tests.Tree string commandLine = "\"C:\\SharpDevelop\\bin\\Tools\\NUnit\\nunit-console-x86.exe\" " + "\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\" " + - "/noshadow " + + "/noshadow /noxml " + "/results=\"c:\\temp\\tmp66.tmp\" " + "/run=\"MyTests.MyTestClass.MyTestMethod\""; Assert.AreEqual(commandLine, message); diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestInPadCommandTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestInPadCommandTestFixture.cs index dbb49a143e..e008a885e4 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestInPadCommandTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestInPadCommandTestFixture.cs @@ -79,7 +79,7 @@ namespace UnitTesting.Tests.Tree { runCommand.Run(); buildProject.FireBuildCompleteEvent(); - string expectedArgs = "\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\""; + string expectedArgs = "\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\" /noxml"; Assert.AreEqual(expectedArgs, processRunner.CommandArgumentsPassedToStartMethod); } diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestWithDebuggerCommandTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestWithDebuggerCommandTestFixture.cs index 6babf3d975..6aa2a63386 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestWithDebuggerCommandTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestWithDebuggerCommandTestFixture.cs @@ -34,7 +34,7 @@ namespace UnitTesting.Tests.Tree public void DebuggerStartsUnitTestApplicationWithCorrectCommandLineArguments() { string expectedArguments = - "\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\""; + "\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\" /noxml"; string actualArguments = debuggerService.MockDebugger.ProcessStartInfo.Arguments; Assert.AreEqual(expectedArguments, actualArguments); @@ -54,7 +54,7 @@ namespace UnitTesting.Tests.Tree { string expectedText = "\"D:\\SharpDevelop\\bin\\Tools\\NUnit\\nunit-console-x86.exe\" " + - "\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\"\r\n"; + "\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\" /noxml\r\n"; string actualText = context.UnitTestCategory.Text; Assert.AreEqual(expectedText, actualText); diff --git a/src/AddIns/Analysis/UnitTesting/UnitTesting.csproj b/src/AddIns/Analysis/UnitTesting/UnitTesting.csproj index bdf1445c65..77590cce8d 100644 --- a/src/AddIns/Analysis/UnitTesting/UnitTesting.csproj +++ b/src/AddIns/Analysis/UnitTesting/UnitTesting.csproj @@ -126,7 +126,7 @@ Component - +