Vector Test Unit for Visual Studio Code
This extension provides support for creating tests for CANoe4SW Server Edition and the Vector Test Unit Runner. Tests for CANoe4SW Server Edition and the Vector Test Unit Runner are provided as so-called "test units". A test unit consists of several test cases implemented in one or more source files.
Metadata of the test unit and references to the test source files are described in a vtestunit.yaml
file. A so-called "test execution tree" defines the overall structure of a test - consisting of test groups, test sequences, and test cases. A test execution tree is described in a vtesttree.yaml
file. The actual test implementation of the test cases and test sequences is done in CAPL.
The Vector Test Unit extension requires a Vector toolset to be installed. The Vector toolset comes with the commercial product CANoe4SW Server Edition. It is also part of the freely available Vector Test Unit Runner.
By default, the latest version of the Vector toolset is used. To select a specific version, use the command VectorTestUnit: Select Vector toolset
or the button in the status bar. The selection is persisted per workspace.
Your selection is synchronized across all Vector extensions you have installed.
Validation of vtestunit.yaml and vtesttree.yaml
If you have the YAML extension installed this extension automatically provides it with the YAML schemata for vtestunit.yaml
and vtesttree.yaml
. This way you can catch schema violations early when working with those files.
These file formats are described below.
For a more detailed documentation, please refer to the help documents of your selected Vector toolset.
Test Implementation
This extension interacts with the Vector CAPL extension. It extends the capabilities of the Vector CAPL extension to write tests in CAPL, i.e., it provides full support for all CAPL features which can only be used in test source files. For the Vector Test Unit extension to recognize a file as a test source file the file must be defined as source in any vtestunit.yaml
inside the workspace. Furthermore, it requires the Vector Simulation and Test Environment extension to be installed.
vtestunit.yaml
In a vtestunit.yaml
file a test unit is described using yaml syntax.
Note that vtestunit.yaml
is not the file name, but a file extension, e.g., filename.vtestunit.yaml
.
In order to compile and execute the test unit described in a vtestunit.yaml
file, a Vector toolset is required.
The following block demonstrates the structure of a vtestunit.yaml
file. Note that only the version
element is mandatory.
version: 1.1.0
includes:
...
test-unit-information:
...
test-unit-implementation:
...
The test-unit-information
element lists general, optional information about the test unit.
The following example demonstrates how this element could be defined.
test-unit-information:
caption: This is a caption
description: This is a description
version: 1
test-designers:
- name: Max
department: PND123
- name: Lisa
department: PND456
additional-information:
- name: Software Under Test
CustomerName: X012
SpareNumber: 0 145 Y03
SRSBaseline: 4.1
Test Unit Implementation
The test-unit-implementation
element lists all artifacts that belong to the test implementation.
It is a list of key-value pairs, each of which must match one of the following key definitions (oneOf
).
These are relative or absolute paths to files in source form, but also compiled libraries.
Relative paths are resolved relative to the *.vtestunit.yaml file.
source-file-path
: Path to a CAPL file (*.can), encrypted CAPL file (*.canencr) or vtesttree.yaml file.
capl-library-path
: Path to a CAPL library (*.dll).
modeling-library-path
: Path to a modeling library (*.vmodule).
The following example demonstrates how this element could be defined.
test-unit-implementation:
# test tree
- source-file-path: MyTestTree.vtesttree.yaml
# feature tests
- source-file-path: MyFeatureTest.can
- source-file-path: MyEncCaplTest.canencr
# diagnostic tests
- source-file-path: D:/dev/MyDiagTest.can
# libs
- capl-library-path: custom.dll
- capl-library-path: custom2.dll
- modeling-library-path: path/to/MyModelingLibrary.vmodule
vtesttree.yaml
In a vtesttree.yaml
file a test execution tree is described using yaml syntax.
Note that vtesttree.yaml
file is not a file name but a file extension, e.g., filename.vtesttree.yaml
.
A vtesttree.yaml
file uses the following structure:
version: 1.0.0
test-tree:
- ...
Test Execution Tree
The test execution tree determines in which order test cases and test sequences are executed.
The tests are executed from top to bottom in the order they appear in the file.
The corresponding test cases and test sequences have to be defined within source files that are referenced by the same vtestunit.yaml
file that references the vtesttree.yaml
file.
Test groups can be used to further structure the test execution tree.
The following is an example of a vtesttree.yaml
file.
test-tree:
- capl-test-case: MyTestCase
title: My Test Case Title
- capl-test-sequence: MyTestSequence
- test-group: MyTestGroup
elements:
- capl-test-case: MyParametrizedTestCase
description: This is a parametrized test case
params: [1, 2]
Definition of the capl functions used in the example above:
export testcase MyTestCase() {
...
}
export testcase MyParametrizedTestCase(int param1, int param2) {
...
}
export testsequence MyTestSequence() {
...
}