[WorkItem(72)] // Regression test for bug #72: CodeCoverage conversion - conversion errors should be detected and reported public void Conv_OutputIsCaptured() { // Arrange TestLogger logger = new TestLogger(); string testDir = TestUtils.CreateTestSpecificFolder(this.TestContext); string outputFilePath = Path.Combine(testDir, "output.txt"); string inputFilePath = Path.Combine(testDir, "input.txt"); File.WriteAllText(inputFilePath, "dummy input file"); string converterFilePath = Path.Combine(testDir, "converter.bat"); File.WriteAllText(converterFilePath, @" echo Normal output... echo Error output...>&2 echo Create a new file using the output parameter echo foo > """ + outputFilePath + @""""); // Act bool success = CoverageReportConverter.ConvertBinaryToXml(converterFilePath, inputFilePath, outputFilePath, logger); // Assert Assert.IsTrue(success, "Expecting the process to succeed"); Assert.IsTrue(File.Exists(outputFilePath), "Expecting the output file to exist"); this.TestContext.AddResultFile(outputFilePath); logger.AssertMessageLogged("Normal output..."); logger.AssertErrorLogged("Error output..."); }
public void ProcRunner_ExecutionSucceeded() { // Arrange string exeName = TestUtils.WriteBatchFileForTest(TestContext, @"@echo Hello world xxx yyy @echo Testing 1,2,3... "); TestLogger logger = new TestLogger(); ProcessRunnerArguments args = new ProcessRunnerArguments(exeName, logger); ProcessRunner runner = new ProcessRunner(); // Act bool success = runner.Execute(args); // Assert Assert.IsTrue(success, "Expecting the process to have succeeded"); Assert.AreEqual(0, runner.ExitCode, "Unexpected exit code"); logger.AssertMessageLogged("Hello world"); // Check output message are passed to the logger logger.AssertMessageLogged("Testing 1,2,3..."); logger.AssertErrorLogged("'xxx' is not recognized as an internal or external command,"); // Check error messages are passed to the logger }