Vector Test Unit for Visual Studio CodeThis extension supports you in creating and editing Vector test units ( It interacts with the CAPL, Python, and C# extensions and provides them with type libraries which are necessary to write test implementations. It provides editing support for test unit configuration files with file endings Depending on your use case it can also assist you in building, running and debugging the test unit. PrerequisitesThe Vector Test Unit extension requires a Vector toolset to be installed. The Vector toolset comes with any CANoe or CANoe Server Edition. It is also part of the freely available Vector Test Unit Runner. Note, that the DevOps workflow is only available with the Server Editions of CANoe and Vector Test Unit Runner as of toolset version 17. The CANoe workflow is only available with the Desktop Editions of CANoe as of toolset version 18. The currently selected toolset is shown in the status bar.
By default, the latest installed version is used.
To select a specific version, use the command The Vector Simulation and Test Environment extension is installed automatically as a dependency. For editing the actual test implementations, please install the respective programming language extensions CAPL, Python, and C#. UsageThe Vector Test Unit extension supports two different workflows. The DevOps workflow is tailored towards the Server Editions of CANoe and Vector Test Unit Runner. The CANoe workflow is for editing vtestunit.yaml-based test units in CANoe editions with a GUI. All test units in the current workspace are discovered by their description files For an explanation of the concepts, terms and file formats, please refer to the help of your Vector toolset, for example by using the Editing description filesThe extension provides editing support for the description files ![]() Editing test implementationsWith this extension all CAPL test files referenced in the test unit description file of the active test unit and all included files will automatically have the test-specific CAPL features enabled. For editing tests written in C# or Python this extension will enable you to ...
In case of C# tests the extension additionally enables you to use the .NET assemblies referenced in the test unit description file. In case of Python the packages referenced in the test unit description file should be resolved by default by the Pylance extension. The C# and Python language support is updated at startup and when changing the active test unit.
If you want to update it manually, e.g. when you have just written a CAPL function that you now want to use in a C# or Python test file you can do so using the commands ![]() DevOps workflowIn the DevOps workflow, the environment must be described in an environment description file ( Building a test unitBefore a test unit can be executed it must be built.
The extension provides a build task that can be executed using the commands
Running a test unitThis extension provides a Test Explorer for executing the whole test unit or individual tests. It gives a visual representation of the test tree and directly shows the status of each test tree element. If your test unit uses variants, you can select a variant value in the bottom of the Test Explorer. Running tests in the Test Explorer requires at least version 18 of the Vector toolset. The resulting test report can be opened by clicking on the link in the test run output. ![]() Test runs can be customized via a Debugging a test unit and simulation (CAPL only)To enable debugging for CAPL, you first need to build debug symbols via one of the following commands:
Note that debug symbols can impact the performance. You can choose to debug only the test unit or the simulation without affecting the performance of the other. ![]() BreakpointsSimply click next to the line number in your CAPL program to set a breakpoint. Via the checkbox in the Run and Debug sidebar you can control if you want the simulation to automatically pause when a test unit breakpoint is hit. Otherwise the simulation keeps running while the test unit is paused. ![]() Known limitations
CANoe workflowFor Vector toolsets beginning with version 18, this extension can also be used to edit YAML-based test units from CANoe in Visual Studio Code. To run your tests, please use the Test Configuration window in CANoe. First, you must configure Visual Studio Code as editor for test unit description files. The setting can be found in the CANoe options under External Programs > Tools > Editor for test units of format vtestunit.yaml. ![]() Afterwards you can click the Open Test Design button of the Test Configuration window to edit your test unit in Visual Studio Code. ![]() The environment from your CANoe configuration (e.g., system variables and distributed objects) will be available in your test implementations. ![]() ExamplePlease refer to the documentation installed with your Vector toolset for details on how to implement test units. This chapter just provides a short example to facilitate getting started with writing test units for CANoe and Vector Test Unit Runner. A test unit is described using a YAML file with file ending
A test execution tree specifies in which order test cases and test sequences are executed.
It is described using a YAML file with file ending
The actual test implementation in
FAQ
This extension takes
In case of any troubles with C# IntelliSense, we recommend configuring the C# extension to use the OmniSharp Language Server instead of the default one. You can do this by enabling the following two workspace settings:
Please note that this will disable the
The Vector Test Unit extension runs an HTTP server on localhost during test execution. Windows asks if this server shall be accessible from outside. As this is not necessary, you may accept or decline as you wish. Keep in mind though that the decision may affect other VS Code extensions, too. |