Modified the protocol to send a the list of tests to run and to invoke the test runner with the wait command flag so that the runner waits for this list.

Modified the reporting channel factory to have a create for the adapter and a create for the runner channel. Also added an event to the create runner channel that people can listen and be notified when a test runner channel was created. I use this event to give the message handler access to the runner channel.

Added the new message handler to DotnetTest.
This commit is contained in:
Livar Cunha 2016-03-03 17:43:42 -08:00
parent 3ed9361763
commit e498f1dc9d
19 changed files with 311 additions and 36 deletions

View file

@ -20,6 +20,7 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
private GetTestRunnerProcessStartInfoMessageHandler _testGetTestRunnerProcessStartInfoMessageHandler;
private Message _validMessage;
private TestStartInfo _testStartInfo;
private List<string> _testsToRun;
private Mock<ITestRunner> _testRunnerMock;
private Mock<ITestRunnerFactory> _testRunnerFactoryMock;
@ -32,10 +33,11 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
public GivenATestExecutionGetTestRunnerProcessStartInfoMessageHandler()
{
_testsToRun = new List<string> {"test1", "test2"};
_validMessage = new Message
{
MessageType = TestMessageTypes.TestExecutionGetTestRunnerProcessStartInfo,
Payload = JToken.FromObject(new RunTestsMessage { Tests = new List<string> { "test1", "test2" } })
Payload = JToken.FromObject(new RunTestsMessage { Tests = _testsToRun })
};
_dotnetTestMock = new Mock<IDotnetTest>();
@ -63,7 +65,7 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
_reportingChannelFactoryMock = new Mock<IReportingChannelFactory>();
_reportingChannelFactoryMock.Setup(r =>
r.CreateChannelWithAnyAvailablePort()).Returns(_testRunnerChannelMock.Object);
r.CreateTestRunnerChannel()).Returns(_testRunnerChannelMock.Object);
_testGetTestRunnerProcessStartInfoMessageHandler = new GetTestRunnerProcessStartInfoMessageHandler(
_testRunnerFactoryMock.Object,
@ -149,7 +151,7 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
_dotnetTestMock.Object,
_validMessage);
_reportingChannelFactoryMock.Verify(r => r.CreateChannelWithAnyAvailablePort(), Times.Once);
_reportingChannelFactoryMock.Verify(r => r.CreateTestRunnerChannel(), Times.Once);
}
[Fact]
@ -172,6 +174,16 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
_dotnetTestMock.Verify(d => d.StartListeningTo(_testRunnerChannelMock.Object), Times.Once);
}
[Fact]
public void It_sets_the_TestsToRun_of_DotnetTest()
{
_testGetTestRunnerProcessStartInfoMessageHandler.HandleMessage(
_dotnetTestMock.Object,
_validMessage);
_dotnetTestMock.VerifySet(d => d.TestsToRun = _testsToRun);
}
[Fact]
public void It_passes_the_right_arguments_to_the_run_tests_arguments_builder()
{
@ -185,8 +197,6 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
arguments.Should().Contain("--port", $"{TestRunnerPort}");
arguments.Should().Contain($"{AssemblyUnderTest}");
arguments.Should().Contain("--test", "test1");
arguments.Should().Contain("--test", "test2");
}
}
}