Java
The following sections provide information on using Testspace with popular Java
test frameworks and tools.
To push collected files simply use the Testspace client
:
$ testspace static-analysis-results test-results code-coverage-results
Test Frameworks
JUnit
JUnit is a simple framework to write repeatable tests. It's an instance of the xUnit architecture for unit testing frameworks.
Java JUnit sample: https://github.com/testspace-samples/java.junit
Note: The description that follows assumes that you are using Apache Maven with the Surefire Plugin to run your JUnit tests.1
Testspace accepts JUnit XML formatted JUnit Test results. Here is an example of how to produce such:
mvn surefire:test
In the Testspace client
command-line reference ./target/surefire-reports/TEST-*.xml
as "test-results" files.
TestNG
TestNG is a testing framework inspired from JUnit and NUnit but introducing some new functionalities that make it more powerful and easier to use.
Java TestNG sample: https://github.com/testspace-samples/java.testng
Note: The description that follows assumes that you are using Apache Maven with the Surefire Plugin to run your JUnit tests.2
Testspace accepts JUnit XML formatted TestNG Test results. Here is an example of how to produce such:
mvn surefire:test
In the Testspace client
command-line reference ./target/surefire-reports/junitreports/TEST-*.xml
as "test-results" files.
Code Coverage
Atlassian Clover
Atlassian Clover provides Java and Groovy code coverage for software testing.
Testspace accepts Clover XML formatted results. Please consult the Clover's documentation on how to create in your environment. For example using Apache Maven with the Clover Plugin to produce such simply run:
mvn clover:clover
In the Testspace client
command-line reference ./target/site/clover/clover.xml
as "code-coverage-results" file.
Covertura
Cobertura is a code coverage utility for Java.
Testspace accepts Cobertura XML formatted results. Please consult Cobertura's documentation on how to create in your environment. For example using Apache Maven with the Cobertura Plugin to produce such simply run:
mvn cobertura:cobertura
In the Testspace client
command-line reference ./target/site/cobertura/coverage.xml
as "code-coverage-results" file.
JaCoCo
JaCoCo is a code coverage library for Java.
Testspace accepts JaCoCo XML formatted results. Please consult the JaCoCo's documentation on how to create in your environment. For example using Apache Maven with the JaCoCo Plugin to produce such simply run:
mvn jacoco:report
In the Testspace client
command-line reference ./target/site/jacoco/jacoco.xml
as "code-coverage-results" file.
Static Analysis
Compiler
Any compiler relies on static analysis of the source code during compilation to generate its errors and warnings.
Testspace accepts GCC/Emacs style formatted build output logs. Simply write your build output to a file, e.g. build.log
.
In the Testspace client
command-line reference build.log{lint}
as "static-analysis-results" file.
Android lint
Android lint is a code scanning tool that can help identifying and correcting problems with the structural quality of Java code.
Testspace accepts Android lint XML formatted results. Here is an example of how to produce such:
lint --fullpath --xml analysis.xml /path/to/project
In the Testspace client
command-line reference analysis.xml
as "static-analysis-results" file.
Checkstyle
Checkstyle is a development tool to help programmers write Java code that adheres to a coding standard.
Testspace accepts Checkstyle XML formatted results. Here is an example of how to produce such:
java -jar checkstyle-7.4-all.jar -f xml -o analysis.xml /path/to/source
In the Testspace client
command-line reference analysis.xml
as "static-analysis-results" file.
PMD
PMD is a source code analyzer for Java.
Testspace accepts PMD XML formatted results. Here is an example of how to produce such:
pmd/bin/run.sh -format xml -reportfile analysis.xml -dir /path/to/source
In the Testspace client
command-line reference analysis.xml
as "static-analysis-results" file.
- If you aren't already using JUnit with Maven, please see this article which describes the needed configuration.↩
- If you aren't already using TestNG with Maven, please see this article which describes the needed configuration.↩