Cantata: Configure Build Commands File Location
In order to generate tests for source files, Cantata must obtain information about the source files. To do this, it needs to know how to compile the files. Compile information can be provided through a build commands file, allowing Cantata to automatically generate the data (.csi files) it needs.
Use this command to select the file (typically called 'build_commands.json' or 'compile_commands.json') that contains compile information for the source files you will be testing.
See the Cantata documentation for information on how to use the cppbch tool to generate this file, or for other ways to produce the required .csi data.
Two commands are provided to open the test script configuration view:
Cantata: Open Testscript Generator
This will open the test script configuration view with no source files pre-loaded.
Use the add source file button, or hold shift while dragging a source file from the explorer view to add files to be tested.
Cantata: Generate Test Script
This will open the test script configuration view with the active editor's source file pre-loaded.
More source files can be selected as described above.
Provided Visual Studio Code Menu Entries
Cantata: Generate Test Script
This menu entry behaves the same as the command described above.
It is available when right-clicking a source file in the Explorer view. The test configuration view is automatically populated with the file selected in the explorer.
It is available when right-clicking within a source file displayed in the editor view. The test configuration view is automatically populated with the file open in the editor.
Cantata: Add file(s) to Test Script Generator
Available when right-clicking a source file in the Explorer view or inside the code editor, if the Generate Test Script view is already open.
This will add the selected source file to the list of files to test, if not already present.
Provided Visual Studio Code Views
Cantata Test Script Configuration View
This view allows setting of the options for a Cantata test script.
Files selected for testing are listed on the left. It is recommended that these are selected before continuing to set other options, as some options' values and applicability depends on the files selected.
A base directory for the tests can be specified at the top. In many cases, this can be pre-selected for you, but may be modified if desired. This base directory will contain the project-level options file for the tests and, if using Cantata makefiles, will contain the Cantata tests directory.
Basic settings such as the script name and coverage rule set can be selected on the first tab.
Where testing C++ code that contains abstract classes, the second tab may be used to create concrete, testable subclasses for use in the test script.
The third tab provides control over call interfaces using stubs, wrappers and isolates. Search and bulk edit features allow you to quickly find and control the functions you need.
Further options, available within the VS Code settings view, may affect the settings and the test generated. Each setting and its effect is described within the settings view.
Known Issues
Modifying the content of selected SUT files after adding them to the view, but before generating the test, may cause test generation to fail.