Test Runner test started needs to handle messages when dotnet test is in a TestStarted state, as we will receive multiple test started messages. Also, to prevent a crash, when we get a message that terminates the adapter or the runner, we need to stop listening. Unfortunately, this needs to be directly where we read the messages, because if we give a handler a chance to handle that message, the reader will already be trying to read again.

This commit is contained in:
Livar Cunha 2016-02-25 17:36:13 -08:00
parent b00a75e3ea
commit 46b1fb42c0
3 changed files with 33 additions and 3 deletions

View file

@ -36,7 +36,7 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
}
[Fact]
public void It_returns_NoOp_if_the_dotnet_test_state_is_not_TestExecutionSentTestRunnerProcessStartInfo()
public void It_returns_NoOp_if_the_dotnet_test_state_is_not_TestExecutionSentTestRunnerProcessStartInfo_or_TestExecutionTestStarted()
{
var dotnetTestMock = new Mock<IDotnetTest>();
dotnetTestMock.Setup(d => d.State).Returns(DotnetTestState.Terminated);
@ -59,7 +59,7 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
}
[Fact]
public void It_returns_TestExecutionStarted_when_it_handles_the_message()
public void It_returns_TestExecutionStarted_when_it_handles_the_message_and_current_state_is_TestExecutionSentTestRunnerProcessStartInfo()
{
var nextState = _testRunnerTestStartedMessageHandler.HandleMessage(
_dotnetTestMock.Object,
@ -68,6 +68,19 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
nextState.Should().Be(DotnetTestState.TestExecutionStarted);
}
[Fact]
public void It_returns_TestExecutionStarted_when_it_handles_the_message_and_current_state_is_TestExecutionTestStarted()
{
var dotnetTestMock = new Mock<IDotnetTest>();
dotnetTestMock.Setup(d => d.State).Returns(DotnetTestState.TestExecutionStarted);
var nextState = _testRunnerTestStartedMessageHandler.HandleMessage(
dotnetTestMock.Object,
_validMessage);
nextState.Should().Be(DotnetTestState.TestExecutionStarted);
}
[Fact]
public void It_sends_a_TestExecutionTestStarted_when_it_handles_the_message()
{