public static void LogsTestNameWithExceptionAndStackTraceAndOutput() { var testFailed = Substitute.For <ITestFailed>(); var test = Mocks.Test(null, "???"); testFailed.Test.Returns(test); testFailed.ExecutionTime.Returns(1.2345M); testFailed.Messages.Returns(new[] { "This is my message \t\r\n" }); testFailed.StackTraces.Returns(new[] { "Line 1\r\nLine 2\r\nLine 3" }); testFailed.ExceptionTypes.Returns(new[] { "ExceptionType" }); testFailed.ExceptionParentIndices.Returns(new[] { -1 }); testFailed.Output.Returns("This is\t\r\noutput"); var formatter = Substitute.For <TeamCityDisplayNameFormatter>(); formatter.DisplayName(test).Returns("This is my display name \t\r\n"); var logger = new SpyConsoleLogger(); using (var visitor = new TeamCityVisitor(logger, null, null, _ => "myFlowId", formatter)) { visitor.OnMessage(testFailed); Assert.Collection(logger.Messages, msg => Assert.Equal("##teamcity[testFailed name='This is my display name \t|r|n' details='ExceptionType : This is my message \t|r|n|r|nLine 1|r|nLine 2|r|nLine 3' flowId='myFlowId']", msg), msg => Assert.Equal("##teamcity[testStdOut name='This is my display name \t|r|n' out='This is\t|r|noutput']", msg), msg => Assert.Equal("##teamcity[testFinished name='This is my display name \t|r|n' duration='1234' flowId='myFlowId']", msg) ); } }
public static void LogsMessage(IMessageSinkMessage message, string messageType) { var logger = new SpyConsoleLogger(); using (var visitor = new TeamCityVisitor(logger, null, null)) { visitor.OnMessage(message); var msg = Assert.Single(logger.Messages); Assert.Equal(String.Format("##teamcity[message text='|[{0}|] ExceptionType: ExceptionType : This is my message \t|r|n' errorDetails='Line 1|r|nLine 2|r|nLine 3' status='ERROR']", messageType), msg); } }
public static void LogsTestName() { var testStarting = Substitute.For <ITestStarting>(); var test = Mocks.Test(null, "???"); testStarting.Test.Returns(test); var formatter = Substitute.For <TeamCityDisplayNameFormatter>(); formatter.DisplayName(test).Returns("This is my display name \t\r\n"); var logger = new SpyConsoleLogger(); using (var visitor = new TeamCityVisitor(logger, null, null, _ => "myFlowId", formatter)) { visitor.OnMessage(testStarting); Assert.Single(logger.Messages, "##teamcity[testStarted name='This is my display name \t|r|n' flowId='myFlowId']"); } }
public static void LogsMessage() { var collectionStarting = Substitute.For <ITestCollectionStarting>(); collectionStarting.TestCollection.DisplayName.Returns("Display Name"); var formatter = Substitute.For <TeamCityDisplayNameFormatter>(); formatter.DisplayName(collectionStarting.TestCollection).Returns("formattedTestCollectionDisplayName"); var logger = new SpyConsoleLogger(); using (var visitor = new TeamCityVisitor(logger, null, null, _ => "myFlowId", formatter)) { visitor.OnMessage(collectionStarting); Assert.Collection(logger.Messages, msg => Assert.Equal("##teamcity[testSuiteStarted name='formattedTestCollectionDisplayName' flowId='myFlowId']", msg)); } }
public static void LogsMessage() { var collectionFinished = Substitute.For <ITestCollectionFinished>(); collectionFinished.TestsRun.Returns(2112); collectionFinished.TestsFailed.Returns(42); collectionFinished.TestsSkipped.Returns(6); collectionFinished.ExecutionTime.Returns(123.4567M); collectionFinished.TestCollection.DisplayName.Returns("Display Name"); var formatter = Substitute.For <TeamCityDisplayNameFormatter>(); formatter.DisplayName(collectionFinished.TestCollection).Returns("formattedTestCollectionDisplayName"); var logger = new SpyConsoleLogger(); using (var visitor = new TeamCityVisitor(logger, null, null, _ => "myFlowId", formatter)) { visitor.OnMessage(collectionFinished); Assert.Single(logger.Messages, "##teamcity[testSuiteFinished name='formattedTestCollectionDisplayName' flowId='myFlowId']"); } }
public static void LogsTestName() { var testPassed = Substitute.For <ITestPassed>(); var test = Mocks.Test(null, "???"); testPassed.Test.Returns(test); testPassed.ExecutionTime.Returns(1.2345M); var formatter = Substitute.For <TeamCityDisplayNameFormatter>(); formatter.DisplayName(test).Returns("This is my display name \t\r\n"); var logger = new SpyConsoleLogger(); using (var visitor = new TeamCityVisitor(logger, null, null, _ => "myFlowId", formatter)) { visitor.OnMessage(testPassed); Assert.Collection(logger.Messages, msg => Assert.Equal("##teamcity[testFinished name='This is my display name \t|r|n' duration='1234' flowId='myFlowId']", msg) ); } }