Skip to content
Ondřej Košarko edited this page Jan 11, 2016 · 1 revision

UnitTesting

Creating test

Running test

DSpace is using Maven SureFire plugin to run the tests. This plugin can be used to run tests prepared in different frameworks like JUnit or TestNG or execute simple POJOs. SureFire plugin needs to be included in the pom.xml file. Which in DSpace is the top level pom.xml (and also dspace/modules/xmlui/pom.xml which is probably not necessary due to pom.xml inheritance).

Running all tests

All the tests are by default run in the test phase. But in DSpace they are skipped due to the following configuration parameter in main pom.xml:

   <!-- skip tests by default, but allow override
      on command line by setting property "-Dmaven.test.skip"-->
      <!-- Disabled by default, change activeByDefault to true to enable -->
      <profile>
        <id>skiptests</id>
        <activation>
            <activeByDefault>true</activeByDefault>
         </activation>
        <properties>
         <maven.test.skip>true</maven.test.skip>
        </properties>
      </profile>

So in order to run the test, one must use:

mvn test -Dmaven.test.skip=false

Running single tests

As tests are just pieces of ordinary software that needs to be debugged it is a common request to run single test only. This can be done by issuing

mvn -q test -Dmaven.test.skip=false -Dtest=$TEST_CLASS

Analyzing test reports

For each test there is a report generated in $DSPACE_SOURCE/$MODULE/target/surefire-reports/

Clone this wiki locally