Skip to content

Commit

Permalink
Coded Test Support (#55)
Browse files Browse the repository at this point in the history
Added support for the new Coded Test feature that will be released with
VectorCAST 24. These changes have no affect on users of older VectorCAST
versions, or users who do not wish to use Coded Tests. The usage of the
Coded Test features is described in the README.md. The following is a
summary of the new features:

- Building an environment with Coded Test support.
- Generating a new Coded Test source file for any unit
- Adding an existing Coded Test source file for any unit
- Editing Coded Test source files, including IntelliSense support
- Update of the test explorer tree to display new tests as they are
added in the editor
- Execution of Coded Tests from the test explorer tree, or by using the
gutter icons in the source editor
- Support for debugging Coded Tests

---------

Co-authored-by: Igor Martinovic <igor.martinovic@vector.com>
  • Loading branch information
johnpaliotta and Zbigor authored Feb 29, 2024
1 parent 64caf1e commit dc9ee52
Show file tree
Hide file tree
Showing 15 changed files with 2,664 additions and 239 deletions.
48 changes: 46 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ setting: "Unit Test Location". By default, this settings value is "./unitTests"
that the environment will be created in the "./unitTests" sub-directory of the directory
containing the source file.

### Coded Testing Support

If you would like to use the Coded Tests feature (VectorCAST 24 and newer), you must
set the "Enable Coded Tests" extension option before building an environment.

### Test Explorer Icons

- The Log icon will open the VectorCAST Test Explorer message panel
Expand Down Expand Up @@ -103,7 +108,19 @@ The right click menu for unit, function, and test nodes has a VectorCAST sub-men
- Delete Test - deletes the selected test
- View Test Results - displays the latest Test Execution Report

### The "Flask+" icon
#### Coded test context menu

If an environment was built with Coded Testing Support enabled (VectorCAST 24 and newer)
The right click context menu for all Coded Test nodes will have a VectorCAST sub-menu with the following commands:

- For a Coded Tests node with no existing tests
- Add Existing Coded Test File - add an existing coded test source file to the node
- Generate New Coded Test File - generate a new coded test source file for the node
- For a coded Tests node with existing tests
- Remove Coded Tests - will remove the coded test file from the node. The test file will NOT be deleted


### The "Flask+" Icon

Special "Flask+" icons are displayed in the margin of the text editor for all VectorCAST
testable functions. This right click menu provides the ability to create a new test script, or
Expand All @@ -125,7 +142,7 @@ In both cases, a progress dialog will be display as the test cases are computed.

Note that the "ATG tests" menu is only available if you are using version of VectorCAST 23sp5 and higher.

### Editing an Existing Test
### Editing an Existing Test Script

To 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
Expand All @@ -152,6 +169,32 @@ When editing a test script file, a "Load Test Script into Environment" right cli
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.

### Editing a Coded Test

Coded test files require an include like this: #include <vunit/vunit.h> so for IntelliSense editing to
work nicely for coded test files, you must add an include path to for this file to your workspace.
IntelliSense include paths can most easily be added to the approrpritate c_cpp_properties.json file.

If you enable the VectorCAST test explorer and configure it with a VectorCAST version that supports coded testing,
the extension will check for the existence of the correct include path and prompt you to add it if it is not found.

You can create a new c_cpp_properties file, by using the: 'C/C++: Edit Configurations (JSON)' command, and can
easily add the required include path, by right clicking on a new or existing file, and choosing: "VectorCAST: Add Coded Test Include Path"

Here is an example a c_cpp_properties.json file with the vUnit include path added:

```
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"C:/VectorCAST/vunit/include"
],
...
```

### Code Coverage Annotations

By default, the extension will display VectorCAST coverage data using green and red bars in the gutter
Expand Down Expand Up @@ -197,6 +240,7 @@ This extension contributes the following settings:
- "VectorCAST Installation Location" provides the path to the VectorCAST installation
- "Unit Test Location" controls where the extension stores unit test new unit test artifacts.
- "Configuration Location" control where the extension looks for the VectorCAST CCAST_.CFG file
- "Enable Coded Tests" enables coded testing when new environments are built
- "Show Report on Execute" will show the HTML test report in after each VectorCAST test run.
- "Decorate Explorer Tree" will add a VC in the right margin of the file explorer tree for those files that have VectorCAST coverage.
- "Verbose Logging" will add more detailed messages to the VectorCAST Test Explorer message panel
Expand Down
116 changes: 105 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "vectorcasttestexplorer",
"displayName": "VectorCAST Test Explorer",
"description": "VectorCAST Test Explorer for VS Code",
"version": "1.0.9",
"license": "See License in file: LICENSE",
"version": "1.0.10",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/vectorgrp/vector-vscode-vcast"
Expand All @@ -26,6 +26,7 @@
"vectorcast",
"vector",
"unittesting",
"c++",
"test",
"testing"
],
Expand Down Expand Up @@ -93,6 +94,11 @@
"category": "VectorCAST Test Explorer",
"title": "VectorCAST: Add Launch Configuration"
},
{
"command": "vectorcastTestExplorer.addIncludePath",
"category": "VectorCAST Test Explorer",
"title": "VectorCAST: Add Coded Test Include Path"
},
{
"command": "vectorcastTestExplorer.addSettingsFileFilter",
"category": "VectorCAST Test Explorer",
Expand All @@ -113,6 +119,21 @@
"category": "VectorCAST Test Explorer",
"title": "New Test Script"
},
{
"command": "vectorcastTestExplorer.addCodedTests",
"category": "VectorCAST Test Explorer",
"title": "Add Existing Coded Test File"
},
{
"command": "vectorcastTestExplorer.generateCodedTests",
"category": "VectorCAST Test Explorer",
"title": "Generate New Coded Test File"
},
{
"command": "vectorcastTestExplorer.removeCodedTests",
"category": "VectorCAST Test Explorer",
"title": "Remove Coded Tests"
},
{
"command": "vectorcastTestExplorer.insertBasisPathTests",
"category": "VectorCAST Test Explorer",
Expand Down Expand Up @@ -143,6 +164,11 @@
"category": "VectorCAST Test Explorer",
"title": "Edit Test Script"
},
{
"command": "vectorcastTestExplorer.editCodedTest",
"category": "VectorCAST Test Explorer",
"title": "Edit Coded Test"
},
{
"command": "vectorcastTestExplorer.loadTestScript",
"category": "VectorCAST Test Explorer",
Expand All @@ -151,7 +177,12 @@
{
"command": "vectorcastTestExplorer.debugEnviroPath",
"category": "VectorCAST Test Explorer",
"title": "Path for environment containing test to be debugged"
"title": "Path for environment containing test being debugged"
},
{
"command": "vectorcastTestExplorer.debugProgramPath",
"category": "VectorCAST Test Explorer",
"title": "Path to executable being debugged"
},
{
"command": "vectorcastTestExplorer.createTestScriptFromEditor",
Expand Down Expand Up @@ -196,21 +227,27 @@
"default": "",
"description": "The file path to an existing VectorCAST configuration that should be used when creating new environments. If a value is not specified, the configuration editor will be launched"
},
"vectorcastTestExplorer.showReportOnExecute": {
"vectorcastTestExplorer.enableCodedTesting": {
"type": "boolean",
"order": 4,
"default": false,
"description": "When this option is set, new environments will be built with the coded testing option enabled"
},
"vectorcastTestExplorer.showReportOnExecute": {
"type": "boolean",
"order": 5,
"default": true,
"description": "Display the VectorCAST execution report after test run"
},
"vectorcastTestExplorer.decorateExplorer": {
"type": "boolean",
"order": 5,
"order": 6,
"default": true,
"description": "Decorate files that have coverage in the File Explorer pane"
},
"vectorcastTestExplorer.verboseLogging": {
"type": "boolean",
"order": 6,
"order": 7,
"default": false,
"description": "Log internal extension details"
}
Expand Down Expand Up @@ -253,6 +290,10 @@
"command": "vectorcastTestExplorer.addLaunchConfiguration",
"when": "never"
},
{
"command": "vectorcastTestExplorer.addIncludePath",
"when": "never"
},
{
"command": "vectorcastTestExplorer.addSettingsFileFilter",
"when": "never"
Expand All @@ -269,6 +310,18 @@
"command": "vectorcastTestExplorer.createTestScript",
"when": "never"
},
{
"command": "vectorcastTestExplorer.addCodedTests",
"when": "never"
},
{
"command": "vectorcastTestExplorer.generateCodedTests",
"when": "never"
},
{
"command": "vectorcastTestExplorer.removeCodedTests",
"when": "never"
},
{
"command": "vectorcastTestExplorer.insertBasisPathTests",
"when": "never"
Expand All @@ -293,6 +346,10 @@
"command": "vectorcastTestExplorer.editTestScript",
"when": "never"
},
{
"command": "vectorcastTestExplorer.editCodedTest",
"when": "never"
},
{
"command": "vectorcastTestExplorer.loadTestScript",
"when": "never"
Expand All @@ -301,6 +358,10 @@
"command": "vectorcastTestExplorer.debugEnviroPath",
"when": "never"
},
{
"command": "vectorcastTestExplorer.debugProgramPath",
"when": "never"
},
{
"command": "vectorcastTestExplorer.createTestScriptFromEditor",
"when": "never"
Expand Down Expand Up @@ -333,6 +394,11 @@
"when": "vectorcastTestExplorer.configured && resourceFilename==launch.json",
"group": "7_modification"
},
{
"command": "vectorcastTestExplorer.addIncludePath",
"when": "vectorcastTestExplorer.codedTestingAvailable && resourceFilename==c_cpp_properties.json",
"group": "7_modification"
},
{
"command": "vectorcastTestExplorer.addSettingsFileFilter",
"when": "vectorcastTestExplorer.configured && resourceFilename==settings.json",
Expand All @@ -358,6 +424,14 @@
{
"command": "vectorcastTestExplorer.loadTestScript",
"when": "vectorcastTestExplorer.configured && resourceExtname==.tst"
},
{
"command": "vectorcastTestExplorer.addLaunchConfiguration",
"when": "vectorcastTestExplorer.configured && resourceFilename==launch.json"
},
{
"command": "vectorcastTestExplorer.addIncludePath",
"when": "vectorcastTestExplorer.codedTestingAvailable && resourceFilename==c_cpp_properties.json"
}
],
"editor/lineNumber/context": [
Expand Down Expand Up @@ -406,27 +480,47 @@
{
"command": "vectorcastTestExplorer.editTestScript",
"group": "vcast@4",
"when": "testId =~ /^vcast:.*$/"
"when": "testId =~ /^vcast:.*$/ && !(testId =~ /.*coded_tests_driver.*/)"
},
{
"command": "vectorcastTestExplorer.createTestScript",
"group": "vcast@5",
"when": "testId =~ /^vcast:.*$/ && testId not in vectorcastTestExplorer.vcastEnviroList"
"when": "testId =~ /^vcast:.*$/ && testId not in vectorcastTestExplorer.vcastEnviroList && !(testId =~ /.*coded_tests_driver.*/)"
},
{
"command": "vectorcastTestExplorer.addCodedTests",
"group": "vcast@4",
"when": "testId =~ /^vcast:.*$/ && testId =~ /.*coded_tests_driver$/ && testId not in vectorcastTestExplorer.vcastHasCodedTestsList"
},
{
"command": "vectorcastTestExplorer.generateCodedTests",
"group": "vcast@5",
"when": "testId =~ /^vcast:.*$/ && testId =~ /.*coded_tests_driver$/ && testId not in vectorcastTestExplorer.vcastHasCodedTestsList"
},
{
"command": "vectorcastTestExplorer.removeCodedTests",
"group": "vcast@6",
"when": "testId =~ /^vcast:.*$/ && testId =~ /.*coded_tests_driver$/ && testId in vectorcastTestExplorer.vcastHasCodedTestsList"
},
{
"command": "vectorcastTestExplorer.editCodedTest",
"group": "vcast@7",
"when": "testId =~ /^vcast:.*$/ && testId not in vectorcastTestExplorer.vcastEnviroList && testId =~ /.*coded_tests_driver.+/"
},
{
"command": "vectorcastTestExplorer.insertBasisPathTests",
"group": "vcast@6",
"when": "testId =~ /^vcast:.*$/ && !(testId =~ /^.*<<COMPOUND>>.*$/) && !(testId =~ /^.*<<INIT>>.*$/)"
"when": "testId =~ /^vcast:.*$/ && !(testId =~ /^.*<<COMPOUND>>.*$/) && !(testId =~ /^.*<<INIT>>.*$/) && !(testId =~ /.*coded_tests_driver.*/)"
},
{
"command": "vectorcastTestExplorer.insertATGTests",
"group": "vcast@7",
"when": "testId =~ /^vcast:.*$/ && vectorcastTestExplorer.atgAvailable && !(testId =~ /^.*<<COMPOUND>>.*$/) && !(testId =~ /^.*<<INIT>>.*$/)"
"when": "testId =~ /^vcast:.*$/ && vectorcastTestExplorer.atgAvailable && !(testId =~ /^.*<<COMPOUND>>.*$/) && !(testId =~ /^.*<<INIT>>.*$/) && !(testId =~ /.*coded_tests_driver.*/)"
},
{
"command": "vectorcastTestExplorer.deleteTest",
"group": "vcast@8",
"when": "testId =~ /^vcast:.*$/"
"when": "testId =~ /^vcast:.*$/ && !(testId =~ /.*coded_tests_driver.*/)"
},
{
"command": "vectorcastTestExplorer.viewResults",
Expand Down
Loading

0 comments on commit dc9ee52

Please sign in to comment.