C++test工具:Parasoft® C/C++test® 是专业针对C和C++语言的开发测试方案,经广泛证明能提高软件开发效率和代码质量的自动化最佳实践解决方案。
如果需要使用C++test的命令行进行自动化测试分析,需要用到cpptestcli命令,并且通常如果需要设置过滤扫描时,可以考虑使用下面的三个关键参数选项:
-resource %RESOURCE%
Specifies a workspace resource path %RESOURCE% to add to the test scope.
Use multiple times to specify multiple resources. Use quotes when the
resource path contains spaces or other non-alphanumeric characters.
If %RESOURCE% is a ".properties" file, the value corresponding to the
key "com.parasoft.eclipse.checker.core.resources" will be interpreted
as a colon(:)-separated list of resources. Only one properties file can
be thus specified. If no resources are specified on the command-line,
the whole workspace will be tested.
Examples:
-resource "MyProject"
-resource "/MyProject/src"
-resource "/MyProject/src/MyClass.cpp"
-resource testedprojects.properties -include %PATTERN%
-exclude %PATTERN%
Specifies files to be included/excluded during testing.
Patterns specify file names or paths, with the wildcards * and ? accepted
and the special wildcard ** used to specify one or more path name segments.
Examples:
-include **/Bank.cpp (test Bank.cpp files)
-include **/ATM/Bank/*.cpp (test all .cpp files in folder ATM/Bank)
-include c:/ATM/Bank/Bank.cpp (test only the c:/ATM/Bank/Bank.cpp file)
-exclude **/internal/** (test everything except files in folder "internal")
-exclude **/*Test.cpp (test everything except files that end with Test.cpp)
List of patterns can be specified in a file with .lst extension.
Each line in .lst file is treated as a single pattern.
Example:
-include c:/include.lst
where include.lst contains:
**/Bank.cpp
**/ATM/Bank/*.cpp
c:/ATM/Bank/Bank.cpp
进一步说明:
-
resource参数这里通常是用来指定待测的项目名称,如果需要指定多个项目,建议利用一个.lst文件,在lst文件中,按照如下方式设定需要扫描的项目:
Shapes
ATM
BugTest
注意:
1) 这里的项目必须是已经导入工作空间的待测试项目,如果不存在,则会报错;
2) 文件中的项目名称不需要使用括号包含;
3) 这里的文件名称必须是.lst结尾。
-
include和exclude参数:这个是用来指定具体路径下或固定模式的代码文件或文件夹,一般建议使用.lst文件,在属性文件中设定包含(include)或排除(exclude)的文件进行扫描。通常include.lst文件如下:
**/Bank.cpp
**/ATM/Bank/*.cpp
c:/ATM/Bank/*
c:/ATM/Bank/Bank.cpp