Skip to content

Architectural Overview

Gabriel Parelli Francischini edited this page Aug 16, 2017 · 1 revision

vsCode VSTest Framework uses the protocol V1 described here: https://github.com/Microsoft/vstest-docs/blob/master/RFCs/0007-Editors-API-Specification.md

RawProtocolSession.ts

Responsible for handling the communication between the server and client. Start the vstest.console.exe/dotnet vstest. Listener for all messages received, push it to a buffer and try to parse it based on the Binary Protocol.
Every rcvd message is appended to the buffer until a readString returns the message itself.


VSTestSession

An extension of the RawProtocolSession specialized on handling the VSTestProtocol V1 messages.
Currently the VSTestSession provides listener to the following events:

  1. onDidTestSessionConnected -> When the session connects to the test host
  2. onDidTestExecutionCompleted -> When the required test execution is completed
  3. onDidTestExecutionStatsChanged -> When the test case changes (result changes)
  4. onDidTestDiscovered -> When a new test case is discovered
  5. onDidTestDiscoveryCompleted -> When the test discovery is completed
  6. onDidTestSessionMessageReceived -> When a new message is received from the host


VSTestModel

The test model is responsible for handling changes on the test cases. It keeps a Dictionary of every discovered test case. Its received the protocol data and transform into the models language.

The Model emit the following message:

  1. onDidTestChanged -> When the test case changes


VSTestService

Responsible for connecting the VSTestSession and VSTestModel. The TestService register a couple of events emmited from the VSTestSession and provide the information to the VSTestModel.


Binary

A simple incomplete Binary Writer and Reader.


VSTestServiceIDE

A implementation of the VSTestService that add the VSCode progress information.


TestTreeDataProvider

The Test Tree implementation. It creates a new vscode.TreeDataProvider to render the tree view. It his duty to organize the result by the required filter

Overview of the Process

The process start by initializing the Test Host. The VSTestServiceIDE figure out what project type is opened and them call the RawTestSession to start a new cmd app and open a new server socket. After launching the server VSTestSession waits the TestSession.Connected message to send the Extensions.Initialize. This command will be based on the project type figured out by VSTestServiceIDE.

Discovery Process

The TestTreeDataProvider comes to the game and request to discovery every test in the solution. The VSTestService needs to figure out which files should be send to the Test Host to have the test retrieved. This is based on the current solution path and a glob pattern defined by the user.

When the VSTestSession receives TestExecution.TestFound it emits the _onDidTestDiscovered that will be handled by the VSTestService. Now the VSTesModel should handle the new test cases that are coming. For every new test the onDidTestChanged event is emitted by the VSTestModel. The TestTreeDataProvider is listen to those messages and asks vscode to render a portion of the tree to keep it updated.

Run Process

When user select a test to run the VSTestService asks the VSTestSession. Every time a test case runs the Test Host reply with a TestExecution.StatsChange. Them the event _onDidTestExecutionStatsChanged is emitted and the VSTestModel take care of keeping the things updated.

Clone this wiki locally