Shared Tests
Brightspot supplies shared tests to catch common mistakes and enforce some invariants and/or constraints. These tests are automatically extracted as part of the build process and run alongside any other tests in the project. The sharedTest
Gradle configuration enables this functionality and is provided by Brightspot’s Gradle plugins. Version 1.0.0 of Shared Tests requires version 2.0.0 or higher of the Brightspot Gradle plugins.
Tests are categorized as either integration tests or unit tests. Integration tests are meant to run as part of the Gradle project which builds the WAR file (typically the web
project), while unit tests are meant to run in the Gradle project(s) which contain the actual classes under test (typically the core
project.
Tests are combined into packs for convenience. Currently, three packs are available:
- pack-standard-backend-integration-tests
- pack-standard-backend-unit-tests
- pack-standard-frontend-unit-tests
Descriptions of all available tests.
Usage
Add shared tests with the sharedTest
configuration:
core/build.gradle
dependencies {
sharedTest 'com.brightspot.shared-tests:pack-standard-backend-unit-tests'
}
frontend/bundles/some-bundle/build.gradle
dependencies {
sharedTest 'com.brightspot.shared-tests:pack-standard-frontend-unit-tests'
}
web/build.gradle
dependencies {
sharedTest 'com.brightspot.shared-tests:pack-standard-backend-integration-tests'
}
Tests can be loaded à la carte if preferred, or to include additional tests not part of a pack: core/build.gradle
dependencies {
sharedTest 'com.brightspot.shared-tests:unit-objecttype-alteration'
}
Legacy usage
Projects using Brightspot’s old Gradle plugin set automatically pull in the old version of shared tests, called shared-unit-tests
. Those tests are deprecated (as are those Gradle plugins) and projects are recommended to upgrade both when possible.
Ignoring Certain Classes for Dynamic Tests
To exclude a certain class from ClassFinder-backed dynamic tests, create a *.ignored.txt
file based on the fully qualified name of the test class. All discovered files will be combined into one set of classes to ignore.
For example, given the testClass name of brightspot.example.ExampleTest
:
- /brightspot/example/ExampleTest.ignored.txt
- /brightspot/example/ignored.txt
- /brightspot/ignored.txt
- /ignored.txt
The following files will also be evaluated, but these files are reserved for internal use only - that is, projects should create *.ignored.txt
files, and *.defaultIgnored.txt
files must only be created in the component-lib project.
- /brightspot/example/ExampleTest.defaultIgnored.txt
- /brightspot/example/defaultIgnored.txt
- /brightspot/defaultIgnored.txt
- /defaultIgnored.txt
This file should be available as a test resource. The format of this file is one class name or regular expression per line. Lines beginning with “#” are treated as comments and ignored.
For typical multi-module Brightspot projects, these files belong in the site
or web
project under “./src/test/resources/…”.