VectorCAST Test ExplorerThis extension supports interacting with VectorCAST/C++ test environments using the VS Code Test Explorer, as well as displaying code coverage as a gutter decoration in C/C++ source editors. PrerequisitesYou must have VectorCAST installed and licensed, and the installation directory must be on the system PATH, set using the VECTORCAST_DIR environment variable or set using the extension option: Vectorcast Installation Location. During extension activation, the prerequisites will be checked, and any errors reported in the VectorCAST Test Explorer output panel. You can check if VectorCAST is on your path by:
You can check if VECTORCAST_DIR is set properly by:
Additionally, if you are using a version of VectorCAST that is older than VectorCAST 23, you must manually add the crc32 utilities to your VectorCAST install directory from this GitHub repo: https://github.com/vectorgrp/vector-vcast-crc32. UsageThis extension extends the VS Code Test Explorer. To use the extension, open a folder that contains one or more VectorCAST test environments, then click on the Test Explorer "Flask" icon in the activity bar. Within a few seconds a list of test environments will be displayed with a list of units, functions, and tests for each environment. If you want to initialize a workspace or folder for VectorCAST testing, simply run the command: "VectorCAST Test Explorer: Configure" from the command palette (Use: ctrl-shift-p or View->Command Palette to access), or click on the "Flask" icon in the activity bar, and then click "Configure VectorCAST Tests". Once the extension is configured, you will be able to use the following features: FeaturesMany of the features implemented by this extension are common to the VS Code test explorer. The following sub-sections focus on features that are unique to the VectorCAST Test Explorer. Creating a New Test EnvironmentTo create a new test environment, simply select one or more C/C++ files (.c, .cpp, .cxx, .cc) from the File Explorer view, right click, and select: Create VectorCAST Environment. The new test environment will be created in the location set via the extension setting: "Unit Test Location". By default, this settings value is "./unitTests" which means that the environment will be created in the "./unitTests" sub-directory of the directory containing the source file. Test Explorer Icons
The Test TreeThe VectorCAST Test Tree contains a hierarchy of nodes for each VectorCAST Test Environment. The top-level node will indicate the relative path from the workspace root to the environment. The subsequent levels show units, functions, and test cases. Test Tree Context MenusEnvironment node context menuThe right click context menu for Environment nodes, has a VectorCAST sub-menu with the following commands:
Unit, function, and test node context menuThe right click menu for unit, function, and test nodes has a VectorCAST sub-menu with the following commands:
Creating a New TestTo create a new test, right click on a unit or function node and choose: "New Test Script" from the VectorCAST right-click context menu Editing an Existing TestTo edit an existing test script, right click on an environment, unit, function, or test node and choose: "Edit Test Script" from the VectorCAST right-click context menu Test Script Editing FeaturesThe extension provides Language Sensitive Editing (LSE) feature to support the VectorCAST Test Script syntax. The LSE features are activated, whenever the extension is active and a file with a '.tst' extension is opened in the editor. You can easily create the framework for a new test by using the 'vcast-test' snippet. Just type 'vcast-test' anywhere in the '.tst' file, and then return, and the minimum commands to create a test will be inserted To add a single script line, type TEST. and a list of all possible commands will be displayed. A very helpful LSE features is auto-completion for TEST.VALUE and TEST.EXPECTED lines.
Type TEST.VALUE:, to see a list of all possible unit names, then a dot to see a list of The LSE features make it quick and intuitive to create new VectorCAST test scripts. Test Script ImportingWhen editing a test script file, a "Load Test Script into Environment" right click menu item is available in the editor window to load the test script into the VectorCAST test environment. If there are unsaved changes, the load command will also perform a save. Code Coverage AnnotationsBy default, the extension will display VectorCAST coverage data using green and red bars in the gutter of any file that has code coverage data, and will show the x/y code coverage % in the status bar. This feature can be toggled ON and OFF using the command: "VectorCAST Test Explorer: Toggle coverage annotations" from the command palette, or using the shortcut ctrl-shift-c. Test Case DebuggingThe extension supports debugging VectorCAST tests via the right click Test Context menu or icon. Debugging requires a special launch configuration called: VectorCAST Harness Debug, which can be installed by right clicking on any existing launch.json file in your workspace, and choosing: "VectorCAST: Add Launch Config" When you select "debug" for a test, the extension will prepare the VectorCAST environment for debugging, open the VectorCAST version of the source file for the unit under test, and scroll the file to the start of the function being tested. You then simply need to set a breakpoint and use F5 to start the debugger. Miscellaneous FeaturesIf you would like to exclude the VectorCAST internal files from your file explorer view, you can do so by right clicking on the settings.json for the workspace and choosing: 'VectorCAST: Add Filter for Environment Files'. This will add the patterns for all of the temporary VectorCAST files to the 'files.exclude' list. To open and close the extension-specific message panel, use ctrl-shift-v Extension CommandsThis extension contributes the following settings:
Extension SettingsThis extension contributes the following settings:
Known Issues
ContributingThis extension is open-source, released under the MIT license, and we welcome your contributions.
LicenseCopyright (c) Vector Informatik GmbH Licensed under the MIT license |