public void MessageSink_should_be_able_to_infer_message_type() { var specPass = new SpecPass(1, GetType().Assembly.GetName().Name); var specFail = new SpecFail(1, GetType().Assembly.GetName().Name); var loggingActor = Sys.ActorOf <LoggingActor>(); Sys.EventStream.Subscribe(TestActor, typeof(Debug)); loggingActor.Tell("LOG ME!"); //capture the logged message var foundMessage = ExpectMsg <Debug>(); //format the string as it would appear when reported by multinode test runner var nodeMessageStr = "[NODE1]" + foundMessage; var nodeMessageFragment = "[NODE1] Only part of a message!"; var runnerMessageStr = foundMessage.ToString(); MessageSink.DetermineMessageType(nodeMessageStr).ShouldBe(MessageSink.MultiNodeTestRunnerMessageType.NodeLogMessage); MessageSink.DetermineMessageType(runnerMessageStr).ShouldBe(MessageSink.MultiNodeTestRunnerMessageType.RunnerLogMessage); MessageSink.DetermineMessageType(specPass.ToString()).ShouldBe(MessageSink.MultiNodeTestRunnerMessageType.NodePassMessage); MessageSink.DetermineMessageType(specFail.ToString()).ShouldBe(MessageSink.MultiNodeTestRunnerMessageType.NodeFailMessage); MessageSink.DetermineMessageType("[Node2][FAIL-EXCEPTION] Type: Xunit.Sdk.TrueException").ShouldBe(MessageSink.MultiNodeTestRunnerMessageType.NodeFailureException); MessageSink.DetermineMessageType(nodeMessageFragment).ShouldBe(MessageSink.MultiNodeTestRunnerMessageType.NodeLogFragment); MessageSink.DetermineMessageType("foo!").ShouldBe(MessageSink.MultiNodeTestRunnerMessageType.Unknown); }
public void MessageSink_should_parse_Node_SpecPass_message_correctly() { var specPass = new SpecPass(1, GetType().Assembly.GetName().Name); NodeCompletedSpecWithSuccess nodeCompletedSpecWithSuccess; MessageSink.TryParseSuccessMessage(specPass.ToString(), out nodeCompletedSpecWithSuccess) .ShouldBeTrue("should have been able to parse node success message"); Assert.Equal(specPass.NodeIndex, nodeCompletedSpecWithSuccess.NodeIndex); }
public void MessageSink_should_be_able_to_infer_message_type() { var specPass = new SpecPass(1, "super_role_1", GetType().GetTypeInfo().Assembly.GetName().Name); var specFail = new SpecFail(1, "super_role_1", GetType().GetTypeInfo().Assembly.GetName().Name); var loggingActor = Sys.ActorOf <LoggingActor>(); Sys.EventStream.Subscribe(TestActor, typeof(Debug)); loggingActor.Tell("LOG ME!"); //capture the logged message var foundMessage = ExpectMsg <Debug>(); //format the string as it would appear when reported by multinode test runner var nodeMessageFragment = "[NODE1:super_role_1] Only part of a message!"; var runnerMessageStr = foundMessage.ToString(); try { throw new ApplicationException("test"); } catch (Exception ex) { specFail.FailureExceptionTypes.Add(ex.GetType().ToString()); specFail.FailureMessages.Add(ex.Message); specFail.FailureStackTraces.Add(ex.StackTrace); } var specFailMsg = specFail.ToString(); MessageSink.DetermineMessageType(runnerMessageStr).ShouldBe(MessageSink.MultiNodeTestRunnerMessageType.RunnerLogMessage); MessageSink.DetermineMessageType(specPass.ToString()).ShouldBe(MessageSink.MultiNodeTestRunnerMessageType.NodePassMessage); MessageSink.DetermineMessageType(specFailMsg).ShouldBe(MessageSink.MultiNodeTestRunnerMessageType.NodeFailMessage); MessageSink.DetermineMessageType($"[Node2][{DateTime.UtcNow}][FAIL-EXCEPTION] Type: Xunit.Sdk.TrueException").ShouldBe(MessageSink.MultiNodeTestRunnerMessageType.NodeFailureException); MessageSink.DetermineMessageType(nodeMessageFragment).ShouldBe(MessageSink.MultiNodeTestRunnerMessageType.NodeLogFragment); MessageSink.DetermineMessageType("foo!").ShouldBe(MessageSink.MultiNodeTestRunnerMessageType.Unknown); }
public bool OnMessage(IMessageSinkMessage message) { var resultMessage = message as ITestResultMessage; if (resultMessage != null) { _logger.Tell(resultMessage.Output); Console.WriteLine(resultMessage.Output); } var testPassed = message as ITestPassed; if (testPassed != null) { //the MultiNodeTestRunner uses 1-based indexing, which is why we have to add 1 to the index. var specPass = new SpecPass(_nodeIndex + 1, _nodeRole, testPassed.TestCase.DisplayName); _logger.Tell(specPass.ToString()); Console.WriteLine(specPass.ToString()); //so the message also shows up in the individual per-node build log Passed = true; return(true); } var testFailed = message as ITestFailed; if (testFailed != null) { //the MultiNodeTestRunner uses 1-based indexing, which is why we have to add 1 to the index. var specFail = new SpecFail(_nodeIndex + 1, _nodeRole, testFailed.TestCase.DisplayName); foreach (var failedMessage in testFailed.Messages) { specFail.FailureMessages.Add(failedMessage); } foreach (var stackTrace in testFailed.StackTraces) { specFail.FailureStackTraces.Add(stackTrace); } foreach (var exceptionType in testFailed.ExceptionTypes) { specFail.FailureExceptionTypes.Add(exceptionType); } _logger.Tell(specFail.ToString()); Console.WriteLine(specFail.ToString()); return(true); } var errorMessage = message as ErrorMessage; if (errorMessage != null) { var specFail = new SpecFail(_nodeIndex + 1, _nodeRole, "ERRORED"); foreach (var failedMessage in errorMessage.Messages) { specFail.FailureMessages.Add(failedMessage); } foreach (var stackTrace in errorMessage.StackTraces) { specFail.FailureStackTraces.Add(stackTrace); } foreach (var exceptionType in errorMessage.ExceptionTypes) { specFail.FailureExceptionTypes.Add(exceptionType); } _logger.Tell(specFail.ToString()); Console.WriteLine(specFail.ToString()); } if (message is ITestAssemblyFinished) { Finished.Set(); } return(true); }