public void TrxReader_SingleTrxFileInSubfolder() { // Arrange var testDir = TestUtils.CreateTestSpecificFolder(TestContext); var resultsDir = TestUtils.CreateTestSpecificFolder(TestContext, "Dummy", "TestResults"); var trxFile = TestUtils.CreateTextFile(resultsDir, "no_attachments.trx", @"<?xml version=""1.0"" encoding=""UTF-8""?> <TestRun id=""eb906034-f363-4bf0-ac6a-29fa47645f67"" name=""LOCAL SERVICE@MACHINENAME 2015-05-06 08:38:39"" runUser=""NT AUTHORITY\LOCAL SERVICE"" xmlns=""http://microsoft.com/schemas/VisualStudio/TeamTest/2010""> <TestSettings name=""default"" id=""bf0f0911-87a2-4413-aa12-36e177a9c5b3"" /> <ResultSummary outcome=""Completed""> <Counters total=""123"" executed=""123"" passed=""123"" failed=""0"" error=""0"" timeout=""0"" aborted=""0"" inconclusive=""0"" passedButRunAborted=""0"" notRunnable=""0"" notExecuted=""0"" disconnected=""0"" warning=""0"" completed=""0"" inProgress=""0"" pending=""0"" /> <RunInfos /> <CollectorDataEntries /> </ResultSummary> </TestRun> "); var logger = new TestLogger(); // Act var coverageFilePath = new TrxFileReader(logger).LocateCodeCoverageFile(testDir); // Assert coverageFilePath.Should().BeNull(); // Not finding attachment info in the file shouldn't cause a warning/error logger.AssertErrorsLogged(0); logger.AssertWarningsLogged(0); logger.AssertInfoMessageExists(trxFile); // should be a message referring to the trx }
private static void VerifyProcessRunOutcome(MockProcessRunner mockRunner, TestLogger testLogger, string expectedWorkingDir, bool actualOutcome, bool expectedOutcome) { actualOutcome.Should().Be(expectedOutcome); mockRunner.SuppliedArguments.WorkingDirectory.Should().Be(expectedWorkingDir); if (actualOutcome) { // Errors can still be logged when the process completes successfully, so // we don't check the error log in this case testLogger.AssertInfoMessageExists(Resources.MSG_TFSProcessorCompleted); } else { testLogger.AssertErrorsLogged(); testLogger.AssertErrorLogged(Resources.ERR_TFSProcessorExecutionFailed); } }
public void SonarRunnerHome_MessageLoggedIfAlreadySet() { using (EnvironmentVariableScope scope = new EnvironmentVariableScope()) { scope.SetVariable(SonarRunnerWrapper.SonarRunnerHomeVariableName, "some_path"); // Arrange TestLogger testLogger = new TestLogger(); string exePath = CreateDummarySonarRunnerBatchFile(); string propertiesFilePath = CreateDummySonarRunnerPropertiesFile(); // Act bool success = SonarRunnerWrapper.ExecuteJavaRunner(new AnalysisConfig(), Enumerable.Empty <string>(), testLogger, exePath, propertiesFilePath); // Assert Assert.IsTrue(success, "Expecting execution to succeed"); testLogger.AssertInfoMessageExists(SonarRunner.Shim.Resources.MSG_SonarRunnerHomeIsSet); } }
public void SonarScannerHome_MessageLoggedIfAlreadySet() { using (var scope = new EnvironmentVariableScope()) { scope.SetVariable(SonarScannerWrapper.SonarScannerHomeVariableName, "some_path"); // Arrange var testLogger = new TestLogger(); var mockRunner = new MockProcessRunner(executeResult: true); var config = new AnalysisConfig() { SonarScannerWorkingDirectory = "c:\\workingDir" }; // Act var success = ExecuteJavaRunnerIgnoringAsserts(config, Enumerable.Empty <string>(), testLogger, "c:\\exePath", "f:\\props.txt", mockRunner); // Assert VerifyProcessRunOutcome(mockRunner, testLogger, "c:\\workingDir", success, true); testLogger.AssertInfoMessageExists(SonarScanner.MSBuild.Shim.Resources.MSG_SonarScannerHomeIsSet); } }