Functional Tests - Documentation topics on: functional tests,testing,.

Functional Tests

If you build dotCMS from source code, dotCMS provides Functional tests with the source code which allow you to test the system against functional requirements. Functional tests are developed using user stories to ensure the end result of dotCMS processes (data, return values, outputs, etc.) match the expected user requirements and expectations.


To enable running functional tests from the command line, the following gradle command must be run before deploying dotCMS and building your Tomcat directory (using the ./gradlew deployWarTomcat command mentioned in the developing from source documentation):

./gradlew deployWarTomcatTests

Functional Test URLs

There are diferent ways to call the tests and, depending on the way they are called, the result will change as well. There are three parameters that can be passed to the test server:

ParameterDescriptionDefault Value
classSpecifies which JUnit class to run.If this parameter is not supplied, all the tests are run.
methodSpecifies which test method of a test class you want to run.
(This must be combined with the “class” parameter).
If this parameter is not supplied, all methods are run.
resultTypeValid values are:
  • file: Generates an XML report file in the folder /webapps/ROOT/dotsecure/logs/test/.
  • plain: Displays the results of the tests as plain/text in the browser and console, and also appends the result of the tests to the log file /webapps/ROOT/dotsecure/logs/dotcms-test.log.
    (This method is very useful when testing locally).



Only executes the WebResourceTest class
Executes all the tests


Executes only the categoryAndTagFields method of the ContentResourceTest class.


XML file
Plain/text result
XML File (the default)
Plain/text result
XML File (the default)

Return Code

The test servlet will return one of two codes to indicate the status of the tests:

All tests passed200
Any test failed (even a single test)500

Sample Results

Plain Text

XML File

All Functional Tests Suite

The file contains the names of all the functional test Java classes. This file can be found in the /src/functional-test/java/com/ testing package.

Running the Suite

You may run the test suite in two ways:

  1. Use ant tasks:
    • Execute the test-dotcms task of the build.xml.
  2. Make direct calls to the servlet:
    1. Execute the “deploy-tests” task of the build.xml
    2. Run the application
    3. Make the calls directly to the test servlet.

Adding Tests

You can add unit tests for your classes by adding entries for each class to the test module in the /test/ folder in your dotCMS build folder. This allow you to call your tests directly (specifying the class and/or test method).

If you wish for your tests to be run when the ALLTestsSuite is run, you must also add your tests to the main test suite.

The following shows the format of an entry for a test in the test module:

    @RunWith ( Suite.class )
    @Suite.SuiteClasses ( {
    } )
    public class AllTestsSuite {