From cf3b2b1a4d06bfa97e3c4dba9ac486b83d252863 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Wed, 5 Mar 2014 23:20:23 +0100 Subject: [PATCH] Simplify test includes & excludes in Gradle build This commit aligns our include and exclude filters for test classes with Gradle's standard patterns. Specifically, our patterns now end with ".class" instead of ".*". The aforementioned change makes the exclusion of inner classes unnecessary. Thus, patterns for test classes ending with "TestCase" or "TestSuite" have been deleted. Furthermore, the include and exclude patterns previously used in the spring-test module made it impossible for the FailingBeforeAndAfterMethodsTests class in the 'testng' package to ever be executed by the build. This has been addressed by renaming our JUnit and TestNG variants of FailingBeforeAndAfterMethodsTests and moving the TestNG variant into the 'junit' package so that it can be picked with our standard include pattern for JUnit-based tests. --- build.gradle | 22 ++++++------------- ...ilingBeforeAndAfterMethodsJUnitTests.java} | 6 ++--- ...lingBeforeAndAfterMethodsTestNGTests.java} | 10 +++++---- 3 files changed, 16 insertions(+), 22 deletions(-) rename spring-test/src/test/java/org/springframework/test/context/junit4/{FailingBeforeAndAfterMethodsTests.java => FailingBeforeAndAfterMethodsJUnitTests.java} (97%) rename spring-test/src/test/java/org/springframework/test/context/{testng/FailingBeforeAndAfterMethodsTests.java => junit4/FailingBeforeAndAfterMethodsTestNGTests.java} (95%) diff --git a/build.gradle b/build.gradle index 3d40c547fc..a2824acd16 100644 --- a/build.gradle +++ b/build.gradle @@ -66,8 +66,8 @@ configure(allprojects) { project -> systemProperty("java.awt.headless", "true") systemProperty("testGroups", project.properties.get("testGroups")) scanForTestClasses = false - include(["**/*Tests.*", "**/*Test.*"]) - exclude "**/Abstract*.*" + include(["**/*Tests.class", "**/*Test.class"]) + exclude "**/Abstract*.class" } repositories { @@ -830,25 +830,17 @@ project("spring-test") { useTestNG() // forkEvery 1 scanForTestClasses = false - include(["**/testng/**/*Tests.*", "**/testng/**/*Test.*"]) - // "TestCase" classes are run by other test classes, not the build. - exclude(["**/Abstract*.*", "**/*TestCase.class", "**/FailingBeforeAndAfterMethodsTests.class"]) - // Show standard out and standard error of the test JVM(s) on the console + include(["**/testng/**/*Tests.class", "**/testng/**/*Test.class"]) + exclude "**/Abstract*.class" + // Show STD_OUT & STD_ERR of the test JVM(s) on the console: // testLogging.showStandardStreams = true } test { dependsOn testNG useJUnit() - include(["**/*Tests.*", "**/*Test.*"]) - // In general, we exclude all classes under the 'testng' package. - // "TestCase" classes are run by other test classes, not the build. - // "TestSuite" classes only exist as a convenience to the develper; they - // should not be run by the build. - exclude(["**/testng/**/*.*", "**/Abstract*.*", "**/*TestCase.class", "**/*TestSuite.class"]) - // FailingBeforeAndAfterMethodsTests is actually a JUnit-based test which - // itself runs TestNG manually in order to test our TestNG support. - include "**/testng/FailingBeforeAndAfterMethodsTests" + include(["**/*Tests.class", "**/*Test.class"]) + exclude(["**/Abstract*.class", "**/testng/**/*.*"]) } task aggregateTestReports(type: TestReport) { diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/FailingBeforeAndAfterMethodsTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/FailingBeforeAndAfterMethodsJUnitTests.java similarity index 97% rename from spring-test/src/test/java/org/springframework/test/context/junit4/FailingBeforeAndAfterMethodsTests.java rename to spring-test/src/test/java/org/springframework/test/context/junit4/FailingBeforeAndAfterMethodsJUnitTests.java index 0f4fb93641..98f6ede608 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/FailingBeforeAndAfterMethodsTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/FailingBeforeAndAfterMethodsJUnitTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -60,12 +60,12 @@ import org.springframework.test.context.transaction.BeforeTransaction; * @since 2.5 */ @RunWith(Parameterized.class) -public class FailingBeforeAndAfterMethodsTests { +public class FailingBeforeAndAfterMethodsJUnitTests { protected final Class clazz; - public FailingBeforeAndAfterMethodsTests(final Class clazz) { + public FailingBeforeAndAfterMethodsJUnitTests(final Class clazz) { this.clazz = clazz; } diff --git a/spring-test/src/test/java/org/springframework/test/context/testng/FailingBeforeAndAfterMethodsTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/FailingBeforeAndAfterMethodsTestNGTests.java similarity index 95% rename from spring-test/src/test/java/org/springframework/test/context/testng/FailingBeforeAndAfterMethodsTests.java rename to spring-test/src/test/java/org/springframework/test/context/junit4/FailingBeforeAndAfterMethodsTestNGTests.java index 74e8f2513a..25ff94b227 100644 --- a/spring-test/src/test/java/org/springframework/test/context/testng/FailingBeforeAndAfterMethodsTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/FailingBeforeAndAfterMethodsTestNGTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.test.context.testng; +package org.springframework.test.context.junit4; import static org.junit.Assert.assertEquals; @@ -30,6 +30,8 @@ import org.springframework.test.context.TestContext; import org.springframework.test.context.TestExecutionListener; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.support.AbstractTestExecutionListener; +import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; +import org.springframework.test.context.testng.AbstractTransactionalTestNGSpringContextTests; import org.springframework.test.context.transaction.AfterTransaction; import org.springframework.test.context.transaction.BeforeTransaction; import org.testng.ITestContext; @@ -62,7 +64,7 @@ import org.testng.TestNG; * @since 2.5 */ @RunWith(Parameterized.class) -public class FailingBeforeAndAfterMethodsTests { +public class FailingBeforeAndAfterMethodsTestNGTests { protected final Class clazz; protected final int expectedTestStartCount; @@ -71,7 +73,7 @@ public class FailingBeforeAndAfterMethodsTests { protected final int expectedFailedConfigurationsCount; - public FailingBeforeAndAfterMethodsTests(final Class clazz, final int expectedTestStartCount, + public FailingBeforeAndAfterMethodsTestNGTests(final Class clazz, final int expectedTestStartCount, final int expectedTestSuccessCount, final int expectedFailureCount, final int expectedFailedConfigurationsCount) { this.clazz = clazz;