Skip to content

Setup Test Resources

Rob Rudin edited this page Oct 14, 2025 · 5 revisions

If the mlTestRestPort property is specified in your gradle.properties file and given a port number value, then the next time you deploy your MarkLogic application, the following additional resources are created.

  • A test database with a default name of ${mlAppName}-test-content
    • The database properties are a replica of ${mlAppName}-content
  • A test REST server named ${mlAppName}-test
    • The application server properties are a replica of ${mlAppName}
    • The database points to ${mlAppName}-test-content
    • The modules database points to ${mlAppName}-modules

The benefit of having a separate test database is that you can run tests, such as with marklogic-unit-test, against the test database without the tests being impacted by data in your main database. Additionally, the marklogic-junit5 library attempts to clear most of the database before it runs a test. You may not want that done against your main database, which may contain a large amount of data that you use for ad hoc testing.

Updating both databases at once

Assuming the use of a file named content-database.json in the databases directory - e.g. src/main/ml-config/databases/content-database.json - ml-gradle will then apply any updates made in content-database.json to both the main and test content databases. For this to work though, the content-database.json must contain the following:

"database-name": "%%DATABASE%%",

ml-gradle will first replace the %%DATABASE%% token with the main content database name and update that database. It will then update that token with the test database name and update that database.

Customizing the test server name

As of version 3.3.1, the names of the REST server and test REST server can be modified by manipulating the mlAppConfig object in build.gradle:

ext {
  mlAppConfig.restServerName = "my-custom-name"
  mlAppConfig.testRestServerName = "my-custom-test-name"
}
Clone this wiki locally