In this section:
You can specify the input scope for your analysis, which includes the file or set of files to test, as well as the test data location. Use one of the following ways:
Use the -resource
switch to specify the file or set of files for testing (also see Running Static Analysis for information on pointing to the data location). You can use multiple -resource
switches to specify multiple resources.
resource [pattern] |
Configure the jtest.resource
property in the .properties file. Separate multiple resources with a comma:
jtest.resource=pattern1,pattern2 |
If you use Ant or Maven, you can use the following pattern:
<resource>pattern</resource> |
You can use the <resources>
element to define multiple resources
<resources> <resource>pattern1</resource> <resource>pattern2</resource> </resources> |
Resource patterns are matched to generated paths according to the following convention:
ProjectName/resource/inside/of/project/directory.extension ProjectName/EXT/resource/inside/of/external/source/directories.extension |
The ProjectName value is generated according to following rules:
You can customize the Maven and Gradle project names with theprojectNameTemplateparameter. For details, see the build system plug-in manuals: [INSTALL]/manuals/ plugins-manual.html.
Generated paths include the EXT string if the specified scope includes external resources. For example, an analyzed project may include sourcefilesformanotherlocationthatarelinkedto the project. In the following example the Simple.java file is located within the Demo project, whereas the Money.java file has been added by linking and itslocationsisoutsideof the project:
Demo/src/main/java/examples/eval/Simple.java Demo/EXT/examples/bank/Money.java |
You can use Ant-style wildcards and other parameters to refine patterns. The following table describes supported usage:
Parameter | Description |
---|---|
? | Wildcard that matches one character (any character except path separators) |
* | Wildcard that matches zero or more characters (not including path separators) |
** | Wildcard that matches zero or more path segments. |
/ | Separator for all operating systems |
"[non-alphanumeric characters]" | Use quotation marks when resource paths contain spaces or other non-alphanumeric characters. |
If the -resource
argument only contains one value, the value is matched against the project name and a wildcard (*) will be used. The following table shows examples of -resource
switch usage.
Expression | Result |
---|---|
-resource ProjectName/src | Analyzes every file in the selected directory and subdirectories (withoutwildcards, the complete name of the folder has to be specified). |
-resource ProjectName/**/*.java | Analyzes every Java filefromselectedproject. |
-resource **/src/main/java/my/company/*.java | Analyzes every Java file from the specific subdirectory of every projectincurrentbuild. |
-resource ProjectName/src/main/java/my/company/File.java | Analyzes the single specified resource. |
-resource c:/resource.lst | Analyzes the projects listed in the |
Use the -include and -exclude switches to apply additional filters to the scope.
-include
instructs Static Analysis Engine to test only the files that match the file system path; all other files are skipped.-exclude
instructs Static Analysis Engine to test all files except for those that match the file system path.If both switches are specified, then all files that match -include
, but not those that match -exclude
patterns are tested.
-include pattern -exclude pattern |
Alternatively, you can specify the pattern in the .properties file with the following options:
jtest.include=pattern jtest.exclude=pattern |
If you use Ant or Maven, you can use the following pattern:
<include>pattern</include> <exclude>pattern</exclude> |
Use Ant-style wildcards and other parameters to with the -include
and -exclude
filters. The following table describes their usage:
Parameter | Description |
---|---|
? | Wildcard that matches one character (any character except path separators) |
* | Wildcard that matches zero or more characters (not including path separators) |
** | Wildcard that matches zero or more path segments. |
/ | Separator |
path: | Prefix for matching absolute disk path |
You can specify a file system path to a list file (*.lst) to include or exclude files in bulk. Each item in the *.lst file is treated as a separate entry.
Usage | Description |
---|---|
-include com/** | Tests everything in packages that begin with "com". |
-include path:**/Bank.java | Tests only Bank.java files |
-include path:C:/Project/src/** | Tests all subfiles and subdirectories of C:/Project/src |
-include path:C:/Project/src/* | Tests all files in C:/Project/src, but not subdirectories |
-include c:/include.lst | Tests all files listed in |
-exclude **/internal/** | Tests everything except classes that have "internal" as part of the package name. |
You can use the -project.*
switch to create a project file, which contains necessary information about executing DTP Engines. Use the -projec
t switch when the solution is not provided. The switch can be used multiple times to analyze many projects. ANT-style wildcards are also supported, as well as paths to *.lst
files. The following table describes the parameters for using -project
switches.
Parameter | Description |
---|---|
-project.location | Enables generation of a file and indicates where the file will be placed after generation. All other -project.* options are ignored if the -project.location option is not set. |
-project.name | Sets the project name. |
-project.encoding | Sets the encoding of the project. |
-project.sourcepath | Sets the source of project. Use this option multiple times to specify multiple source folders. |
-project.sourcelevel | Specifies the Java compiler compliance level. |
-project.classpath | Specifies the classpath. |
-project.javahome | Used to find and add the library to the bootclasspath |
-project.classpath.jars.dir | Specifies the path to the directory with jars that should be appended to the project classpath. View the json file to verify the order of the jars and ensure it meets your project requirements. |
-project.junit.outcomes | Specifies the path to the XML file with JUnit test results that will be used to generate a report. Use this option multiple times to specify multiple report files. |
-project.compilation.classes | Specifies the path to the compiled project classes that will be used to generate metadata information required to perform the "Calculate Application Coverage" configuration. |
-project.location C:/ExampleProject -project.name ExampleProject -project.encoding UTF-8 -project.sourcepath C:/ExampleProject/src -project.sourcelevel C:/ExampleProject/src-test -project.classpath C:/ExampleProject/lib/test.jar;C:/ExampleProject/lib/test2.jar -project.javahome C:/Program Files/Java/jdk1.7 |