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 Configure the If you use Ant or Maven, you can use the following pattern: You can use the Resource patterns are matched to generated paths according to the following convention: 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: You can use Ant-style wildcards and other parameters to refine patterns. The following table describes supported usage: If the Analyzes the projects listed in the Use the -include and -exclude switches to apply additional filters to the scope. If both switches are specified, then all files that match Alternatively, you can specify the pattern in the .properties file with the following options: If you use Ant or Maven, you can use the following pattern: Use Ant-style wildcards and other parameters to with the 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. Tests all files listed in In typical scenarions, Jtest runs on To manually create a data file Jtest will use for analysis, run The Required. Enables generation of the .json file by specifying the root of the project. Provide the absolute path to an existing directory. For example: All paths included in the Jtest report generated after analysis will be relative to the root of the project configured with this option.Overview
-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]
jtest.resource
property in the .properties file. Separate multiple resources with a comma:jtest.resource=pattern1,pattern2
Ant and Maven Pattern
<resource>pattern</resource>
<resources>
element to define multiple resources<resources>
<resource>pattern1</resource>
<resource>pattern2</resource>
</resources>
Resource Pattern Syntax
ProjectName/resource/inside/of/project/directory.extension
ProjectName/EXT/resource/inside/of/external/source/directories.extension
Demo/src/main/java/examples/eval/Simple.java
Demo/EXT/examples/bank/Money.java
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. -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
resource.lst
file. Specify one project name per line:ProjectName1
ProjectName2
Provide the path to the file as a value to the -resource
argument.Fine-tuning 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. -include
, but not those that match -exclude
patterns are tested.-include pattern
-exclude pattern
jtest.include=pattern
jtest.exclude=pattern
Ant and Maven Pattern
<include>pattern</include>
<exclude>pattern</exclude>
-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 Examples
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
include.lst
. Each line is treated as a single pattern.
Example:
If include.lst
contains the following lines: **/*Account
path:**/Bank.java
It has the same effect as the following command:-include **/*Account
-include path: **/Bank.java
-exclude **/internal/**
Tests everything except classes that have "internal" as part of the package name. Creating Custom .json Data Files
jtest.data.json
data files that are automatically generated by build system plugins. Alternatively, you can manually create a .json file and provide Jtest with the path to that file using the -data
command line option (see Running Static Analysis). jtestcli
with the -project
options. The available options are listed in the table below.example.data.json
file is created in the root of the project configured with the -project.location
option.Parameter Description -project.location
-project.location /home/adam/projects/myproject1
-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. Example
-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