dotnet-installer/src/dotnet/commands/dotnet-test
Livar 105536dc38 Making the dotnet test images relative paths.
skip CI please

Otherwise, it will only work in our branch.

This is a documentation only change.
2016-03-28 11:14:50 -07:00
..
MessageHandlers Modifying the reporting channels to make the AdapterChannel a client and leave the TestRunnerChannel a server. This will prevent port conflicts between dotnet test and the Adapter (VS) due to race conditions. 2016-03-15 15:13:54 -07:00
ReportingChannels Modifying the reporting channels to make the AdapterChannel a client and leave the TestRunnerChannel a server. This will prevent port conflicts between dotnet test and the Adapter (VS) due to race conditions. 2016-03-15 15:13:54 -07:00
TestRunners 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. 2016-03-04 17:14:56 -08:00
AssemblyUnderTest.cs Added build before running the tests and the no-build option to opt out of it. 2016-03-17 15:17:18 -07:00
BaseDotnetTestRunner.cs Added build before running the tests and the no-build option to opt out of it. 2016-03-17 15:17:18 -07:00
CommandTestRunnerExtensions.cs Changing from serializing ProcessStartInfo to our own TestStartInfo class, because serializing ProcessStartInfo doesn't really work cross-platform due to unsupported properties. 2016-03-01 21:53:51 -08:00
ConsoleTestRunner.cs Added build before running the tests and the no-build option to opt out of it. 2016-03-17 15:17:18 -07:00
DesignTimeRunner.cs Added build before running the tests and the no-build option to opt out of it. 2016-03-17 15:17:18 -07:00
dotnet-test.xproj Revert "Update the .xproj files to reference the "DotNet" targets and props instead of "DNX"." 2016-03-16 11:44:09 -05:00
DotnetTest.cs 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. 2016-03-04 17:14:56 -08:00
DotnetTestExtensions.cs 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. 2016-03-04 17:14:56 -08:00
DotnetTestParams.cs Added a Help property to DotnetTestParams that indicates when the parsed arguments included the help param. The TestCommand then uses this property of the params to decide whether to continue with the execution or just return. Also added unit tests around this as well as introduced a DotnetTestRunnerFactory to make these unit tests possible and also push the responsibility to figure out which runner to use to the factory. 2016-03-25 20:17:15 -07:00
DotnetTestRunnerFactory.cs Added a Help property to DotnetTestParams that indicates when the parsed arguments included the help param. The TestCommand then uses this property of the params to decide whether to continue with the execution or just return. Also added unit tests around this as well as introduced a DotnetTestRunnerFactory to make these unit tests possible and also push the responsibility to figure out which runner to use to the factory. 2016-03-25 20:17:15 -07:00
DotnetTestState.cs Adding unit tests for the state machine of dotnet test. Starting the implementation of a state machine in dotnet test. Right now we only handle the TestSession:Terminate message. 2016-02-23 11:20:04 -08:00
IDotnetTest.cs 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. 2016-03-04 17:14:56 -08:00
IDotnetTestRunner.cs Added extra params (base-build-path, runtime, framework) and refactored parameter parsing into its own class with tests. 2016-03-17 13:29:16 -07:00
IDotnetTestRunnerFactory.cs Added a Help property to DotnetTestParams that indicates when the parsed arguments included the help param. The TestCommand then uses this property of the params to decide whether to continue with the execution or just return. Also added unit tests around this as well as introduced a DotnetTestRunnerFactory to make these unit tests possible and also push the responsibility to figure out which runner to use to the factory. 2016-03-25 20:17:15 -07:00
ITestMessagesCollection.cs Adding unit tests for the state machine of dotnet test. Starting the implementation of a state machine in dotnet test. Right now we only handle the TestSession:Terminate message. 2016-02-23 11:20:04 -08:00
Program.cs Added a Help property to DotnetTestParams that indicates when the parsed arguments included the help param. The TestCommand then uses this property of the params to decide whether to continue with the execution or just return. Also added unit tests around this as well as introduced a DotnetTestRunnerFactory to make these unit tests possible and also push the responsibility to figure out which runner to use to the factory. 2016-03-25 20:17:15 -07:00
readme.md Making the dotnet test images relative paths. 2016-03-28 11:14:50 -07:00
TestHostTracing.cs Everything in the same project 2016-02-01 14:56:32 -08:00
TestMessagesCollection.cs This fixes a race condition where if the runner takes to long to execute and we get two messages before the runner quits, we hit a blocking piece of code when trying to add new messages to the queue, which leads to a deadlock, where we need to finish the runner to process new messages but the runner won't quit because it is waiting for us to accept is other messages. 2016-03-03 00:11:13 -08:00
TestStartInfo.cs Changing from serializing ProcessStartInfo to our own TestStartInfo class, because serializing ProcessStartInfo doesn't really work cross-platform due to unsupported properties. 2016-03-01 21:53:51 -08:00

Dotnet Test, Adapters and Test Runners

This document covers the interactions between dotnet test, a potential adapter (like VS) and test runners (like xunit).

It describes the communication protocol for these agents, the parameters that the runner needs to support and the modes on which dotnet test and the runner work.

Running modes

Dotnet test supports two running modes:

  1. Console: In console mode, dotnet test simply executes fully whatever command gets passed to it and outputs the results. Anytime you invoke dotnet test without passing --port, it will run in console mode, which in turn will cause the runner to run in console mode.
  2. Design time: Anytime you pass a port to dotnet test, we will run in design time. That means that dotnet test will connect to that port using TCP and will then exchange a established set of messages with whatever else is connected to that port. When this happens, the runner also receives a port (a new one, mind you) that dotnet test will use to communicate with it. The reason why the runner also uses TCP to communicate with dotnet test is because in design mode, it is not sufficient to just output results to the console. We need to send the adapter structure messages containing the results of the test execution.

Communication protocol in design time.

  1. Because during design time, dotnet test connects to a port when it starts up, the adapter needs to be listening on that port otherwise dotnet test will fail. We did it like this so that the adapter could reserve all the ports it needs by binding and listening to them before dotnet test ran and tried to get ports for the runner.
  2. Once dotnet test starts, it sends a TestSession.Connected message to the adapter indicating that it is ready to receive messages.
  3. It is possible to send an optional version check message with the adapter version of the protocol in it. Dotnet test will send back the version of the protocol that it supports.

All messages have the format described here: Message.cs. The payload formats for each message is described in links to the classes used to de/serialize the information in the description of the protocol.

Test Execution

alt tag

  1. After the optional version check, the adapter sends a TestExecution.GetTestRunnerProcessStartInfo, with the tests it wants to execute inside of it. Dotnet test sends back a FileName and Arguments inside a TestStartInfo payload that the adapter can use to start the runner. In the past, we would send the list of tests to run as part of that argument, but we were actually going over the command line size limit for some test projects.
  2. As part of the arguments, we send a port that the runner should connect to and for executing tests, a --wait-command flag, that indicates that the runner should connect to the port and wait for commands, instead of going ahead and executing the tests.
  3. At this point, the adapter can launch the runner (and attach to it for debugging if it chooses to).
  4. Once the runner starts, it sends dotnet test a TestRunner.WaitCommand message that indicates it is ready to receive commands, at which point dotnet test sends a TestRunner.Execute with the list of tests to run. This bypasses the command line size limit described above.
  5. The runner then sends dotnet test (and it passes forward to the adapter) a TestExecution.TestStarted for each tests as they start with the test information inside of it.
  6. The runner also sends dotnet test (and it forwards to the adapter) a TestExecution.TestResult for each test with the individual result of the test.
  7. After all tests finish, the runner sends a TestRunner.Completed message to dotnet test, which dotnet test sends as TestExecution.Completed to the adapter.
  8. Once the adapter is done, it sends dotnet test a TestSession.Terminate which will cause dotnet test to shutdown.

Test discovery

alt tag

  1. After the optional version check, the adapter sends a TestDiscovery.Start message. Because in this case, the adapter does not need to attach to the process, dotnet test will start the runner itself. Also, since there is no long list of arguments to be passed to the runner, no --wait-command flag is needed to be passed to the runner. dotnet test only passes a --list argument to the runner, which means the runner should not run the tests, just list them.
  2. The runner then sends dotnet test (and it passes forward to the adapter) a TestDiscovery.TestFound for each test found.
  3. After all tests are discovered, the runner sends a TestRunner.Completed message to dotnet test, which dotnet test sends as TestDiscovery.Completed to the adapter.
  4. Once the adapter is done, it sends dotnet test a TestSession.Terminate which will cause dotnet test to shutdown.

Dotnet test parameters

Any parameters not accepted by dotnet test will be forwarded to the runner. This is the list of parameters supported by dotnet test from its own help print out:

Usage: dotnet test [arguments] [options]

Arguments: The project to test, defaults to the current directory. Can be a path to a project.json or a project directory.

Options: -?|-h|--help Show help information --parentProcessId Used by IDEs to specify their process ID. Test will exit if the parent process does. --port Used by IDEs to specify a port number to listen for a connection. -c|--configuration Configuration under which to build -o|--output <OUTPUT_DIR> Directory in which to find the binaries to be run -b|--build-base-path <OUTPUT_DIR> Directory in which to find temporary outputs -f|--framework Looks for test binaries for a specific framework -r|--runtime <RUNTIME_IDENTIFIER> Look for test binaries for a for the specified runtime --no-build Do not build project before testing

Minimum parameters that the runner needs to support

  • AssemblyUnderTest: Path to the dll that contains the tests to be run.
  • --port: Used by dotnet test to specify a port number that the runner should connect to.
  • --list: Indicates that the tests should only be listed and not executed.
  • --designtime: Indicates that the runner is running in design time, for instance, inside an adapter.
  • --wait-command: Indicates that the runner should wait to receive commands through the TCP channel instead of running tests right away. We use this to get around the command line size limit.