Using gradle, there is possibility to divide unit tests from in example module or integration tests stage. Even there is possibility to create few tests stages for different purposes.
Let’s imagine that in code there is need to have unit tests, module tests, functional tests and integration tests. To achieve that, one of the best way is to create separation in gradle modules at packages and run related tests according to selected method. For such a solution may be used gradle feature offering tasks.
At first there have to exclude classes with chosen pattern from goal “test”. To do that, add following in build.gradle (in example in section subprojects at root):
Next we would like to have test reports in different targets. It may be important when job executed is in CI and we would like to zip a folder with test results. Probably also dividing may be needed when file collision is in generated files.
Finally need to create a build.gradle for module that will contain separated tests.
To run just use:
You may use as many tasks defined in gradle as you need.
Posted in: Sortware