Skip to content

Testing

Martin Večeřa edited this page Nov 26, 2023 · 12 revisions

Important

!!! When running tests, always set the following environment variable to skip Auth0 authentication:

SKIP_SECURITY=true

Skipping resource limits

You might want to disable checking for exceeding resource limits of the free plan. This is done by setting the following environment property:

SKIP_LIMITS=true

Unit tests

Unit tests are automatically run every time you build the project using the following command:

$ mvn clean install

You may also want to run just a single test class:

$ mvn clean test -Dtest=YourTestClass

... or a specific method:

$ mvn clean test -Dtest=YourTestClass#yourTestMethod

Integration tests

Integration tests are the ones which needs a container (WildFly) to run. They are switched off by default because it takes more time to run them. To explicitly run them, use the following command:

$ mvn clean verify -Ptests

You can also run just a single test class or a specific method:

$ mvn clean verify -Ptests -Dit.test=YourTestClass#yourTestMethod

Running tests in IDE

If you want to run integration tests in your IDE, you have to properly configure its Arquillian extension. The tests need to use Arquillian container configuration called WildFly Managed with wildfly-managed qualifier set. If you have the test configuration like this, you should be easily able to run integration tests directly in your IDE.

Make sure your IDE do not use tests Maven profile. Otherwise, this approach will not work.

Debugging tests in IDE

If you want to debug tests in your IDE, you have to properly configure war/src/test/resources/arquillian.xml file and add new container for debugging.

   <container qualifier="debug">
      <configuration>
         <property name="jbossHome">${project.build.directory}/wildfly-14.0.1.Final</property>
         <property name="javaVmArguments">-Xmx1024m [paste config line from IntelliJ IDEA - see below]</property>
      </configuration>
   </container>

Make sure to set also these elements in your debug settings:

  • Remote Debug
  • Transport: Socket
  • Debugger mode: Attach
  • Host: localhost
  • Port: 5005

Example configuration:

Sometimes, IDE complains about already existing deployment lumeer-test.war. To resolve this:

  1. Edit war/target/wildfly-30.0.0.Final/standalone/configuration/standalone.xml and near the bottom of the file, completely remove <deployments>...</deployments> section.
  2. Remove war/target/wildfly-30.0.0.Final/standalone/[data,log,tmp] directories.