Skip to content

Commit

Permalink
cleaned up the SpecPass / SpecFail messages (#4912)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaronontheweb authored Apr 6, 2021
1 parent ec3fc61 commit 85ef5d8
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 39 deletions.
3 changes: 0 additions & 3 deletions src/core/Akka.MultiNodeTestRunner.Shared/Sinks/Spec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,12 @@ public SpecFail(int nodeIndex, string nodeRole, string testDisplayName) : base(n
FailureMessages = new List<string>();
FailureStackTraces = new List<string>();
FailureExceptionTypes = new List<string>();
Timestamp = DateTime.UtcNow;
}

public IList<string> FailureMessages { get; private set; }
public IList<string> FailureStackTraces { get; private set; }
public IList<string> FailureExceptionTypes { get; private set; }

public DateTime Timestamp { get; }

public override string ToString()
{
var sb = new StringBuilder();
Expand Down
72 changes: 36 additions & 36 deletions src/core/Akka.NodeTestRunner/Sink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,47 +40,47 @@ public Sink(int nodeIndex, string nodeRole, IActorRef logger)

public bool OnMessage(IMessageSinkMessage message)
{
var resultMessage = message as ITestResultMessage;
if (resultMessage != null)
if (message is ITestResultMessage resultMessage)
{
_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)

switch (message)
{
Finished.Set();
case ITestPassed testPassed:
{
//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;
}
case ITestFailed testFailed:
{
//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;
}
case ErrorMessage errorMessage:
{
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());
break;
}
case ITestAssemblyFinished _:
Finished.Set();
break;
}

return true;
Expand Down

0 comments on commit 85ef5d8

Please sign in to comment.