The aim of testsuite module is to provide unit and integration tests for Resteasy. All newly added tests go into this module. The integration tests run with specified Wildfly server.
- arquillian-utils - contains helper classes used often in tests like - help methods for creating the deployment, categories for tests, server setup task etc.
- integration-tests - contains tests to run in container (Wildfly)
- integration-tests-spring - tests for resteasy integration with spring
- integration-tests-embedded - contain tests that are configured to run in each of the standalone containers, (Undertow, Vertx, Netty4, Sun jdk).
- unit-tests - standalone tests not running in container
- Keep structure of the tests example.
- Document test class and all tests within test class see [Test Documentation](#Test Documentation). It will help others to understand.
- Provide RESTEASY jira number if possible, it will help to track the issue in the future.
- For integration tests avoid using concrete address like "http://localhost:8080". Tests don't need to be run always on the default hostname/port. See example above.
- If you keep in mind above points, you will help us to keep Resteasy testsuite organized and stable.
- Dependencies for testsuite are managed from single point
../resteasy-dependencies-bom/pom.xml
- Pom file above contains all dependencies versions managed via dependency management.
- Use the pom above to specify dependency version and in your pom in testsuite module use only:
<dependency>
<groupId>group.id</groupId>
<artifactId>arttifact.id</artifactId>
<!-- If needed <scope>test</scope> -->
</dependency>
Run default tests (excluding the ones expected to fail) with the default container (it is automatically downloaded):
mvn clean verify
Run default tests (excluding the ones expected to fail) with path to the container specified:
mvn clean verify -Dserver.home=PATH_TO_WIDLFLY_HOME
By default all tests annotated with @Category({ ExpectedFailing.class })
are excluded.
To run the testsuite with failing tests included for testing purposes:
mvn clean verify -Dserver.home=PATH_TO_WIDLFLY_HOME -Denable.expected.failing -fn
mvn surefire:test@default-test -Dserver.home=PATH_TO_WIDLFLY_HOME -Dtest=NAME_OF_THE_TEST_CLASS -fn
When running microprofile-tck
tests, use the following in order to activate WireMock:
mvn wiremock:run -Dparams="--port=8765" -Ddir="target/classes" surefire:test@default-test -Dserver.home=PATH_TO_WIDLFLY_HOME -Dtest=NAME_OF_THE_TEST_CLASS -fn
To run test JsonBindingTest requires the use of a speciality surefire syntax.
mvn surefire:test@jsonb-test -Dserver.home=PATH_TO_WIDLFLY_HOME -Dtest=JsonBindingTest -fn
"@jsonb-test" is the id of a surefile execution definition in the pom file.
Test JsonBindingAnnotationsJacksonTest is run with command
mvn surefire:test@default-test -Dserver.home=PATH_TO_WIDLFLY_HOME -Dtest=JsonBindingAnnotationsJacksonTest -fn
Resteasy version for unit-tests and for client side of integration tests can be specified with -Dversion.resteasy.testsuite=RESTEASY_VERSION
mvn clean verify -Dserver.home=PATH_TO_WIDLFLY_HOME -Dversion.resteasy.testsuite=RESTEASY_VERSION
Use ipv6
property and specify IP address for EAP binding for IPv6 testing. Example:
mvn clean verify -Dserver.home=PATH_TO_WIDLFLY_HOME -Dnode=2620:52:0:2804:56ee:75ff:fe1d:44c3 -Dipv6
Run testsuite or test with the Wildfly with security manager enabled:
mvn clean verify -Dserver.home=PATH_TO_WIDLFLY_HOME -Dsecurity.manager
Test logs are stored in /MODULE_NAME/target/surefire-reports/TEST_NAME-output.txt
To redirect to standard output (console) use -Dmaven.test.redirectTestOutputToFile=false
.
mvn clean verify -Dserver.home=PATH_TO_WIDLFLY_HOME -Dmaven.test.redirectTestOutputToFile=false
The testsuite can run in two modes, which differ by security subsystem configuration and by subsystem used in the tests, which require security domain defined.
The tests which require security domain configuration are extending org.jboss.resteasy.setup.AbstractUsersRolesSecurityDomainSetup
which implements ServerSetupTask.
Tests run with PicketBox security domain. This is the default.
Tests run with Elytron security domain. Activate this mode by:
mvn clean verify -Dserver.home=PATH_TO_WIDLFLY_HOME -Delytron
You can generate Jacoco test coverage report with the following steps.
Jacoco coverage data files are generated under target folder of the each testsuite module.
mvn clean verify -Djacoco
After jacoco data files are generated you can generate jacoco html report.
Run following command to generate html report:
mvn verify -DskipTests -Djacoco.generate.report
open testsuite/target/jacoco-report/index.html
With each new test write appropriate javadoc documentation.
We keep test documentation for test cases (test classes) as follows:
/**
* @tpChapter Main chapter name (see chapter structure below)
* @tpSubChapter Sub-chapter name (see chapter structure below)
* @tpTestCaseDetails Description of the test class, id of JIRA issue if applicable
* @tpSince RESTEasy 3.x.x (in which version of resteasy was this test added)
*/
The test methods itself are annotated as follows:
/**
* @tpTestDetails Description of what the test does
* @tpSince RESTEasy 3.x.x (in which version of resteasy was this test added)
*/
Following is the list of chapters and corresponding subchapters for javadoc test documentation:
-
Unit tests
- Crypto
- Injection tests
- Interception tests
- Jose tests
- Media type
- Providers
- Requests
- Resource tests
- Resteasy-client
- Util tests
-
Client tests
- Configuration
- Resteasy-client
-
Integration tests
- Asynchronous RESTEasy
- Atom provider
- CDI
- Constructors
- Core
- Crypto
- DataSource provider
- Encoding
- Exceptions
- Form tests
- IIOImage provider
- Injection
- Interceptors
- Jackson2 provider
- Jackson provider
- Jaxb provider
- Jsapi
- Json-p provider
- Localization
- Multipart provider
- Parameters
- Plain provider
- Providers
- Resources
- Response
- Security
- Util tests
- Validator provider
- Writers
- XXE