public void TrxReader_TrxWithNoAttachments() { // Arrange string testDir = TestUtils.CreateTestSpecificFolder(this.TestContext); string resultsDir = TestUtils.CreateTestSpecificFolder(this.TestContext, "TestResults"); string trxFile = 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> "); TestLogger logger = new TestLogger(); // Act string coverageFilePath = TrxFileReader.LocateCodeCoverageFile(testDir, logger); // Assert Assert.AreEqual(null, coverageFilePath); // Not finding attachment info in the file shouldn't cause a warning/error logger.AssertErrorsLogged(0); logger.AssertWarningsLogged(0); logger.AssertMessageExists(trxFile); // should be a message referring to the trx }
public void TrxReader_SingleAttachment_RelativePath() { // Arrange string testDir = TestUtils.CreateTestSpecificFolder(this.TestContext); string resultsDir = TestUtils.CreateTestSpecificFolder(this.TestContext, "TestResults"); string coverageFileName = "MACHINENAME\\LOCAL SERVICE_MACHINENAME 2015-05-06 08_38_35.coverage"; string textFile = CreateTextFile(resultsDir, "single_attachment.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""> <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> <Collector agentName=""MACHINENAME"" uri=""datacollector://microsoft/CodeCoverage/2.0"" collectorDisplayName=""Code Coverage""> <UriAttachments> <UriAttachment> <A href=""{0}""> </A> </UriAttachment> </UriAttachments> </Collector> </CollectorDataEntries> </ResultSummary> </TestRun>", coverageFileName); TestLogger logger = new TestLogger(); // Act string coverageFilePath = TrxFileReader.LocateCodeCoverageFile(testDir, logger); // Assert string expected = Path.Combine(resultsDir, "single_attachment", "In", coverageFileName); Assert.AreEqual(expected, coverageFilePath); logger.AssertMessageExists(coverageFileName); }