-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lobster-cpptest documentation (#116)
Lobster-cpptest documentation has been adopted. Resolves #57
- Loading branch information
1 parent
72fe2f1
commit 5eb0928
Showing
4 changed files
with
176 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
# Tracing to C/C++ tests | ||
|
||
## Setup and requirements | ||
|
||
You will need a C/C++ file or a directory containing these files. | ||
* Note: The tool also supports a combination of files and folders. | ||
|
||
C/C++ files should have one of these extensions to be evaluated by this tool: `.cpp`, `.cc`, `.c` or `.h` | ||
|
||
## Preparing C/C++ test documentation with requirements | ||
The test functions should be specified with one the following `macros`: | ||
`TEST`, | ||
`TEST_P`, | ||
`TEST_F`, | ||
`TYPED_TEST`, | ||
`TYPED_TEST_P`, | ||
`TYPED_TEST_SUITE`, | ||
`TEST_P_INSTANCE` or | ||
`TEST_F_INSTANCE` | ||
|
||
In your test you need to also add documentation. For example: | ||
|
||
```C++ | ||
/** | ||
* @requirement CB-#0815, CB-#0816, | ||
* CB-#0817 | ||
* @requirement CB-#0818 CB-#0819 | ||
* CB-#0820 | ||
*/ | ||
TEST(ImplicationTest, BasicTest) {} | ||
``` | ||
* Each test can have multiple test types defined in the documentation part. | ||
* Test types can be used multiple times in the test documentation and can be written on multiple lines | ||
* These can be simply defined with `/** Test types */` or `/// Test types` format. | ||
* Test-tags can be separated by commas or spaces. | ||
* Note: The `markers` shall be exactly close to the test functions (without any empty lines) | ||
```C++ | ||
/** | ||
* @requirement CB-#0815, CB-#0816 | ||
*/ | ||
TEST(ImplicationTest, BasicTest) {} | ||
``` | ||
|
||
```C++ | ||
/// | ||
/// @requiredby FOO0::BAR0 | ||
/// | ||
TEST(ImplicationTest, BasicTest) {} | ||
``` | ||
The regex used for each test-tag is as follows: | ||
@requirement | ||
: ```r"(CB-#\d+)"``` | ||
: ```r"({provided codebeamer-url in config-file}(?P<number>\d+))"``` | ||
@requiredby | ||
: ```r"(\w*::\w+)"``` | ||
@defect | ||
: ```r"(CB-#\d+)|(OCT-#\d+)"``` | ||
## Preparing cpptest config-file | ||
You have to provide a config-file which determines which `markers` should be extracted in which output-files. | ||
The expected `kind` for each output-file should also be specified. | ||
In addition, you have to provide the `codebeamer-url`: | ||
```cpp.config | ||
{ | ||
"output": { | ||
"unit_tests.lobster" : | ||
{ | ||
"markers": ["@requirement"], | ||
"kind": "req" | ||
}, | ||
"components_tests.lobster" : | ||
{ | ||
"markers": ["@requiredby", "@requirement"], | ||
"kind": "imp" | ||
} | ||
}, | ||
"codebeamer_url": "https://codebeamer.example.com/test" | ||
} | ||
``` | ||
|
||
* Note: If you want to extract the other tests with other `markers`, | ||
you can use an empty list as `markers` value. Be aware in this case the tests do not have any references. | ||
|
||
```cpp.config | ||
{ | ||
"output": { | ||
"tests.lobster" : | ||
{ | ||
"markers": [], | ||
"kind": "req" | ||
} | ||
}, | ||
"codebeamer_url": "https://codebeamer.example.com/test" | ||
} | ||
``` | ||
|
||
|
||
## Creating lobster files | ||
|
||
Run the `lobster_cpptest` tool, pointing it to one or more C/C++ files, or a directory containing one or more C/C++ files. | ||
|
||
For example `lobster_cpptest .` should find all your C/C++ files in the root directory. | ||
|
||
You have to also provide a `--config-file` file to configure the behaviour of the tool. | ||
A more complete command line might look like: | ||
|
||
```sh | ||
$ lobster-cpptest . --config-file cpp.config | ||
``` | ||
|
||
## Example | ||
|
||
The LOBSTER unit tests contains a working example: | ||
|
||
* Test [test_case.cpp](../test-unit/lobster-cpptest/data/test_case.cpp) containing requirement tags | ||
|
||
## Notes & Caveats | ||
* This tool supports these `markers`: '@requirement', '@requiredby' and '@defect' | ||
* This tool supports these `kind`: 'req', 'imp' and 'act' | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters