The server/test Project

Many of our tests reside in the server/test directory and you can run your tests in that directory using the custom test runner interface or command line. The gradle command is:

gradlew :server:test:uiTests

We use uiTest instead of test because "test", by convention, refers to unit tests, which are run with each build. The "test" name is reserved for possible future development of more unit tests located in a more standard place. By default, this will bring up the UI for the test runner and allow you to choose which tests you want to run, with various other parameters. If you want to run a particular test or suite, you can specify properties on the command line. You use a -P flag to specify the property, not the -D flag previously used with the ant build. For example, to run the DRT tests, you would use the following command

gradlew :server:test:uiTests -Psuite=DRT

You can use the 'test' property to specify a comma-separated list of test classes

gradlew :server:test:uiTests -Ptest=BasicTest,IssuesTest

To retain the artifacts created by the test, use -Pclean=false.

gradlew :server:test:uiTests -Ptest=BasicTest,IssuesTest -Pclean=false

To run a particular test method or methods (annotated @Test) within a test class, append a dot-separated list of methods to the class that contains them.

gradlew :server:test:uiTests -Ptest=BasicTest.testCredits.testScripts,IssuesTest.emailTest

You can also specify properties using the server/test/ file.

Individual Modules

Gradle brings with it the ability to do very targeted builds and tasks, thus we have the ability to run the tests for a particular module without using the test runner project.

Until we resolve the issue of making the test runner able to run tests from all modules while still allowing the individual tests to be run, you must set the project property enableUiTests in order to be able to run the tests for an individual module.

For any module that has its own test/src directory, there will be a task so you can run only the tests for only that module. As of the 1.4.0 release of gradlePlugins, the name of the task is moduleUiTests. Prior to this release, the task is uiTests. So, for example, you can run the tests for MS2 by using this command:

gradlew -PenableUiTests :server:modules:ms2:moduleUiTests

It is still required that you have the :server:test project since that is the location of the "" file and the helper methods for running tests.

Related Topics


Was this content helpful?

Log in or register an account to provide feedback

expand all collapse all