public void MSTest_Suite_Passes() { var results = ProcessExtensions.ExecuteDotnet(testRunner, Quote(msTestTests)); Assert.AreEqual( 0, results.ExitCode, "TestRunner.exe returned non-zero exit code"); Assert.IsTrue( results.Output.Contains(MSTest.MSTestTests.TestCleanupMessage), "[TestCleanup] method did not run"); Assert.IsTrue( results.Output.Contains(MSTest.MSTestTests.ClassCleanupMessage), "[ClassCleanup] method did not run"); Assert.IsTrue( results.Output.Contains(MSTest.MSTestTests.AssemblyCleanupMessage), "[AssemblyCleanup] method did not run"); Assert.IsTrue( results.Output.Contains(MSTest.MSTestTests.TraceTestMessage), "System.Diagnostics.Trace test message was not printed"); Assert.IsFalse( results.Output.Contains(MSTest.MSTestTests.IgnoredTestMessage), "An [Ignore]d test method ran"); }
/// <summary> /// Reinvoke testrunner to run an individual test file in its own process /// </summary> /// static bool Reinvoke(string testFile) { var exitCode = ProcessExtensions.ExecuteDotnet( ProgramPath, $"--inproc --outputformat machine \"{testFile}\"", (proc, line) => { var e = MachineReadableEventSerializer.TryDeserialize(line); EventHandlerPipeline.Raise( e ?? new StandardOutputEvent() { ProcessId = proc.Id, Message = line, }); }, (proc, line) => { EventHandlerPipeline.Raise( new ErrorOutputEvent() { ProcessId = proc.Id, Message = line, }); }); return(exitCode == 0); }
static int Main3(string[] args) { // // Route trace output to stdout // Trace.Listeners.Add(new TestRunnerTraceListener()); // // Parse arguments // ArgumentParser.Parse(args); if (!ArgumentParser.Success) { WriteLine(); WriteLine(ArgumentParser.GetUsage()); WriteLine(); WriteLine(); WriteLine(ArgumentParser.ErrorMessage); return(1); } // // Parent process: Print the program banner and invoke TestRunner --inproc child processes for each // <testassembly> specified on the command line // if (!ArgumentParser.InProc) { Banner(); bool success = true; foreach (var assemblyPath in ArgumentParser.AssemblyPaths) { var exitCode = ProcessExtensions.ExecuteDotnet( ProgramPath, "--inproc \"" + assemblyPath + "\"") .ExitCode; if (exitCode != 0) { success = false; } } return(success ? 0 : 1); } // // Child process: Run the tests in the specified <testassembly> // else { return(TestAssemblyRunner.Run(ArgumentParser.AssemblyPaths[0]) ? 0 : 1); } }
public void No_Class_Switches_Runs_All_Classes() { var results = ProcessExtensions.ExecuteDotnet(testRunner, Quote(includeExcludeTests)); AssertZeroExitCode(results.ExitCode); AssertIncludeExcludeMethodRan(results.Output, "A.A.a()"); AssertIncludeExcludeMethodRan(results.Output, "A.A.b()"); AssertIncludeExcludeMethodRan(results.Output, "A.B.a()"); AssertIncludeExcludeMethodRan(results.Output, "A.B.b()"); AssertIncludeExcludeMethodRan(results.Output, "B.A.a()"); AssertIncludeExcludeMethodRan(results.Output, "B.A.b()"); AssertIncludeExcludeMethodRan(results.Output, "B.B.a()"); AssertIncludeExcludeMethodRan(results.Output, "B.B.b()"); }
public void Qualified_Method_Switch_Does_Not_Include_Other_Unqualified_Methods_In_Class() { var results = ProcessExtensions.ExecuteDotnet( testRunner, Quote("--class", "A.A", "--method", "a", "--method", "B.B.b", includeExcludeTests)); AssertZeroExitCode(results.ExitCode); AssertIncludeExcludeMethodRan(results.Output, "A.A.a()"); AssertIncludeExcludeMethodDidNotRun(results.Output, "A.A.b()"); AssertIncludeExcludeMethodDidNotRun(results.Output, "A.B.a()"); AssertIncludeExcludeMethodDidNotRun(results.Output, "A.B.b()"); AssertIncludeExcludeMethodDidNotRun(results.Output, "B.A.a()"); AssertIncludeExcludeMethodDidNotRun(results.Output, "B.A.b()"); AssertIncludeExcludeMethodDidNotRun(results.Output, "B.B.a()"); AssertIncludeExcludeMethodRan(results.Output, "B.B.b()"); }
public void Unqualified_Method_Switch_Is_Constrained_By_Class_Switches() { var results = ProcessExtensions.ExecuteDotnet( testRunner, Quote("--class", "B.A", "--method", "b", includeExcludeTests)); AssertZeroExitCode(results.ExitCode); AssertIncludeExcludeMethodDidNotRun(results.Output, "A.A.a()"); AssertIncludeExcludeMethodDidNotRun(results.Output, "A.A.b()"); AssertIncludeExcludeMethodDidNotRun(results.Output, "A.B.a()"); AssertIncludeExcludeMethodDidNotRun(results.Output, "A.B.b()"); AssertIncludeExcludeMethodDidNotRun(results.Output, "B.A.a()"); AssertIncludeExcludeMethodRan(results.Output, "B.A.b()"); AssertIncludeExcludeMethodDidNotRun(results.Output, "B.B.a()"); AssertIncludeExcludeMethodDidNotRun(results.Output, "B.B.b()"); }
public void Multiple_Method_Switches_Runs_All_Specified_Methods() { var results = ProcessExtensions.ExecuteDotnet( testRunner, Quote("--method", "A.A.b", "--method", "B.B.b", includeExcludeTests)); AssertZeroExitCode(results.ExitCode); AssertIncludeExcludeMethodDidNotRun(results.Output, "A.A.a()"); AssertIncludeExcludeMethodRan(results.Output, "A.A.b()"); AssertIncludeExcludeMethodDidNotRun(results.Output, "A.B.a()"); AssertIncludeExcludeMethodDidNotRun(results.Output, "A.B.b()"); AssertIncludeExcludeMethodDidNotRun(results.Output, "B.A.a()"); AssertIncludeExcludeMethodDidNotRun(results.Output, "B.A.b()"); AssertIncludeExcludeMethodDidNotRun(results.Output, "B.B.a()"); AssertIncludeExcludeMethodRan(results.Output, "B.B.b()"); }
public void Unqualified_Method_Switch_Runs_Methods_With_That_Name() { var results = ProcessExtensions.ExecuteDotnet( testRunner, Quote("--method", "b", includeExcludeTests)); AssertZeroExitCode(results.ExitCode); AssertIncludeExcludeMethodDidNotRun(results.Output, "A.A.a()"); AssertIncludeExcludeMethodRan(results.Output, "A.A.b()"); AssertIncludeExcludeMethodDidNotRun(results.Output, "A.B.a()"); AssertIncludeExcludeMethodRan(results.Output, "A.B.b()"); AssertIncludeExcludeMethodDidNotRun(results.Output, "B.A.a()"); AssertIncludeExcludeMethodRan(results.Output, "B.A.b()"); AssertIncludeExcludeMethodDidNotRun(results.Output, "B.B.a()"); AssertIncludeExcludeMethodRan(results.Output, "B.B.b()"); }
public void Qualified_Class_Switch_Runs_That_Exact_Class() { var results = ProcessExtensions.ExecuteDotnet( testRunner, Quote("--class", "A.A", includeExcludeTests)); AssertZeroExitCode(results.ExitCode); AssertIncludeExcludeMethodRan(results.Output, "A.A.a()"); AssertIncludeExcludeMethodRan(results.Output, "A.A.b()"); AssertIncludeExcludeMethodDidNotRun(results.Output, "A.B.a()"); AssertIncludeExcludeMethodDidNotRun(results.Output, "A.B.b()"); AssertIncludeExcludeMethodDidNotRun(results.Output, "B.A.a()"); AssertIncludeExcludeMethodDidNotRun(results.Output, "B.A.b()"); AssertIncludeExcludeMethodDidNotRun(results.Output, "B.B.a()"); AssertIncludeExcludeMethodDidNotRun(results.Output, "B.B.b()"); }
/// <summary> /// Reinvoke testrunner to run an individual test file in its own process /// </summary> /// static bool Reinvoke(string testFile) { var args = new List <string>(); args.Add("--inproc"); args.Add("--outputformat machine"); foreach (var @class in ArgumentParser.Classes) { args.Add($"--class {@class}"); } foreach (var method in ArgumentParser.Methods) { args.Add($"--method {method}"); } args.Add($"\"{testFile}\""); var exitCode = ProcessExtensions.ExecuteDotnet( Assembly.GetExecutingAssembly().Location, string.Join(" ", args), (proc, line) => { var e = MachineReadableEventSerializer.TryDeserialize(line); EventHandlerPipeline.Raise( e ?? new StandardOutputEvent() { ProcessId = proc.Id, Message = line, }); }, (proc, line) => { EventHandlerPipeline.Raise( new ErrorOutputEvent() { ProcessId = proc.Id, Message = line, }); }); return(exitCode == 0); }
public void Non_DotNet_Dll_Yields_ExitCode_0() { Assert.AreEqual( 0, ProcessExtensions.ExecuteDotnet(testRunner, Quote(fakeDll)).ExitCode); }
public void Non_Test_Assembly_Yields_ExitCode_0() { Assert.AreEqual( 0, ProcessExtensions.ExecuteDotnet(testRunner, Quote(referencedAssembly)).ExitCode); }
public void Many_Assemblies_With_Different_Config_Files_Pass() { Assert.AreEqual( 0, ProcessExtensions.ExecuteDotnet(testRunner, Quote(msTestTests, differentConfigTests)).ExitCode); }
public void One_Failing_Assembly_In_Many_Yields_ExitCode_1() { Assert.AreEqual( 1, ProcessExtensions.ExecuteDotnet(testRunner, Quote(failTests, passTests)).ExitCode); }
public void Non_Existent_File_Yields_ExitCode_1() { Assert.AreEqual( 1, ProcessExtensions.ExecuteDotnet(testRunner, Quote("no-such.dll")).ExitCode); }
public void Pass_Yields_ExitCode_0() { Assert.AreEqual( 0, ProcessExtensions.ExecuteDotnet(testRunner, Quote(passTests)).ExitCode); }
public void Fail_Yields_ExitCode_1() { Assert.AreEqual( 1, ProcessExtensions.ExecuteDotnet(testRunner, Quote(failTests)).ExitCode); }
public void TestCleanup_Receives_Failed_UnitTestResult_When_Test_Fails() { Assert.IsTrue( ProcessExtensions.ExecuteDotnet(testRunner, Quote(failTests)).Output .Contains("Failed UnitTestOutcome")); }