mirror of
https://github.com/google/nomulus.git
synced 2025-05-29 08:50:09 +02:00
Improve FilteringTest so it works in all cases (#339)
* Improve FilteringTest so it works in all cases - Disable failOnMatchingTests so we don't fail if we filter out all of the tests for any given task. - Add excludeTestCases flag so that we can turn this behavior off for test tasks that need to run TestCas/TestSuite classes. - Add includeAllTests() function for test tasks where we don't explicitly include our required tests. This makes all test tasks in core FilteringTest, with the exception of the default test task which now does nothing (it just depends on the other test tasks). * Improve wording of excludeTestCases comment
This commit is contained in:
parent
2c6d71f04c
commit
301ab54fb4
1 changed files with 45 additions and 14 deletions
|
@ -590,14 +590,43 @@ artifacts {
|
||||||
*/
|
*/
|
||||||
class FilteringTest extends Test {
|
class FilteringTest extends Test {
|
||||||
|
|
||||||
void setTests(List<String> tests) {
|
private void applyTestFilter() {
|
||||||
// Common exclude pattern. See README in parent directory for explanation.
|
|
||||||
exclude "**/*TestCase.*", "**/*TestSuite.*"
|
|
||||||
include tests
|
|
||||||
if (project.testFilter) {
|
if (project.testFilter) {
|
||||||
testNameIncludePatterns = project.testFilter.split(',')
|
testNameIncludePatterns = project.testFilter.split(',')
|
||||||
|
|
||||||
|
// By default, gradle test tasks will produce a failure if no tests
|
||||||
|
// match the include/exclude/filter rules. Since test filtering allows us
|
||||||
|
// to select a set of tests from a particular task, we don't want this
|
||||||
|
// behavior.
|
||||||
|
filter.failOnNoMatchingTests = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set to false if you also want to include TestCase and TestSuite classes.
|
||||||
|
*
|
||||||
|
* <p>Must be defined before "test", if at all.
|
||||||
|
*/
|
||||||
|
boolean excludeTestCases = true
|
||||||
|
|
||||||
|
void setTests(List<String> tests) {
|
||||||
|
// Common exclude pattern. See README in parent directory for explanation.
|
||||||
|
if (excludeTestCases) {
|
||||||
|
exclude "**/*TestCase.*", "**/*TestSuite.*"
|
||||||
|
}
|
||||||
|
include tests
|
||||||
|
applyTestFilter()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Include all of the tests (except Test{Case,TestSuite}). This actually
|
||||||
|
* doesn't explicitly "include" anything, in which cast the Test class tries
|
||||||
|
* to include everything that is not explicitly excluded.
|
||||||
|
*/
|
||||||
|
void includeAllTests() {
|
||||||
|
exclude "**/*TestCase.*", "**/*TestSuite.*"
|
||||||
|
applyTestFilter()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
task fragileTest(type: FilteringTest) {
|
task fragileTest(type: FilteringTest) {
|
||||||
|
@ -620,12 +649,9 @@ task outcastTest(type: FilteringTest) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dedicated test suite for schema-dependent tests.
|
// Dedicated test suite for schema-dependent tests.
|
||||||
task sqlIntegrationTest(type: Test) {
|
task sqlIntegrationTest(type: FilteringTest) {
|
||||||
include 'google/registry/schema/integration/SqlIntegrationTestSuite.*'
|
excludeTestCases = false
|
||||||
// Copied from FilteringTest. Not inheriting b/c it excludes TestSuites.
|
tests = ['google/registry/schema/integration/SqlIntegrationTestSuite.*']
|
||||||
if (project.testFilter) {
|
|
||||||
testNameIncludePatterns = project.testFilter.split(',')
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
task findGoldenImages(type: JavaExec) {
|
task findGoldenImages(type: JavaExec) {
|
||||||
|
@ -710,9 +736,8 @@ task flowDocsTool(type: JavaExec) {
|
||||||
args arguments
|
args arguments
|
||||||
}
|
}
|
||||||
|
|
||||||
test {
|
task standardTest(type: FilteringTest) {
|
||||||
// Common exclude pattern. See README in parent directory for explanation.
|
includeAllTests()
|
||||||
exclude "**/*TestCase.*", "**/*TestSuite.*"
|
|
||||||
exclude fragileTestPatterns
|
exclude fragileTestPatterns
|
||||||
exclude outcastTestPatterns
|
exclude outcastTestPatterns
|
||||||
|
|
||||||
|
@ -734,7 +759,13 @@ test {
|
||||||
doFirst {
|
doFirst {
|
||||||
new File(screenshotsDir).deleteDir()
|
new File(screenshotsDir).deleteDir()
|
||||||
}
|
}
|
||||||
}.dependsOn(fragileTest, outcastTest)
|
}
|
||||||
|
|
||||||
|
test {
|
||||||
|
// Don't run any tests from this task, all testing gets done in the
|
||||||
|
// FilteringTest tasks.
|
||||||
|
exclude "**"
|
||||||
|
}.dependsOn(fragileTest, outcastTest, standardTest)
|
||||||
|
|
||||||
createUberJar('nomulus', 'nomulus', 'google.registry.tools.RegistryTool')
|
createUberJar('nomulus', 'nomulus', 'google.registry.tools.RegistryTool')
|
||||||
project.nomulus.dependsOn project(':third_party').jar
|
project.nomulus.dependsOn project(':third_party').jar
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue