Ensure all tests are executed in the Gradle build

Prior to this commit several test classes named "*Test" were not
recognized as tests by the Gradle build. This is due to the configured
inclusion of '**/*Tests.*' which follows Spring's naming convention for
test classes.

This commit addresses this issue by:

 - Renaming real test classes consistently to "*Tests".
 - Renaming internal test classes to "*TestCase".
 - Renaming @WebTest to @WebTestStereotype.
 - Disabling broken tests in AnnoDrivenStaticEntityMockingControlTest.
 - Modifying the Gradle build configuration so that classes ending in
   either "*Tests" or "*Test" are considered test classes.

Issue: SPR-11384
This commit is contained in:
Sam Brannen
2014-02-03 23:16:47 +01:00
parent 1c5cab2a40
commit b8ed2f4967
18 changed files with 198 additions and 187 deletions

View File

@@ -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.
@@ -174,7 +174,7 @@ public class ContextLoaderUtilsActiveProfilesTests extends AbstractContextLoader
*/
@Test
public void resolveActiveProfilesWithResolver() {
String[] profiles = resolveActiveProfiles(FooActiveProfilesResolverTest.class);
String[] profiles = resolveActiveProfiles(FooActiveProfilesResolverTestCase.class);
assertNotNull(profiles);
assertEquals(1, profiles.length);
assertArrayEquals(new String[] { "foo" }, profiles);
@@ -185,7 +185,7 @@ public class ContextLoaderUtilsActiveProfilesTests extends AbstractContextLoader
*/
@Test
public void resolveActiveProfilesWithInheritedResolver() {
String[] profiles = resolveActiveProfiles(InheritedFooActiveProfilesResolverTest.class);
String[] profiles = resolveActiveProfiles(InheritedFooActiveProfilesResolverTestCase.class);
assertNotNull(profiles);
assertEquals(1, profiles.length);
assertArrayEquals(new String[] { "foo" }, profiles);
@@ -196,7 +196,7 @@ public class ContextLoaderUtilsActiveProfilesTests extends AbstractContextLoader
*/
@Test
public void resolveActiveProfilesWithMergedInheritedResolver() {
String[] profiles = resolveActiveProfiles(MergedInheritedFooActiveProfilesResolverTest.class);
String[] profiles = resolveActiveProfiles(MergedInheritedFooActiveProfilesResolverTestCase.class);
assertNotNull(profiles);
assertEquals(2, profiles.length);
List<String> list = Arrays.asList(profiles);
@@ -209,7 +209,7 @@ public class ContextLoaderUtilsActiveProfilesTests extends AbstractContextLoader
*/
@Test
public void resolveActiveProfilesWithOverridenInheritedResolver() {
String[] profiles = resolveActiveProfiles(OverridenInheritedFooActiveProfilesResolverTest.class);
String[] profiles = resolveActiveProfiles(OverridenInheritedFooActiveProfilesResolverTestCase.class);
assertNotNull(profiles);
assertEquals(1, profiles.length);
assertArrayEquals(new String[] { "bar" }, profiles);
@@ -220,7 +220,7 @@ public class ContextLoaderUtilsActiveProfilesTests extends AbstractContextLoader
*/
@Test(expected = IllegalStateException.class)
public void resolveActiveProfilesWithConflictingResolverAndProfiles() {
resolveActiveProfiles(ConflictingResolverAndProfilesTest.class);
resolveActiveProfiles(ConflictingResolverAndProfilesTestCase.class);
}
/**
@@ -228,7 +228,7 @@ public class ContextLoaderUtilsActiveProfilesTests extends AbstractContextLoader
*/
@Test(expected = IllegalStateException.class)
public void resolveActiveProfilesWithConflictingResolverAndValue() {
resolveActiveProfiles(ConflictingResolverAndValueTest.class);
resolveActiveProfiles(ConflictingResolverAndValueTestCase.class);
}
/**
@@ -236,7 +236,7 @@ public class ContextLoaderUtilsActiveProfilesTests extends AbstractContextLoader
*/
@Test(expected = IllegalStateException.class)
public void resolveActiveProfilesWithConflictingProfilesAndValue() {
resolveActiveProfiles(ConflictingProfilesAndValueTest.class);
resolveActiveProfiles(ConflictingProfilesAndValueTestCase.class);
}
/**
@@ -244,7 +244,7 @@ public class ContextLoaderUtilsActiveProfilesTests extends AbstractContextLoader
*/
@Test(expected = IllegalStateException.class)
public void resolveActiveProfilesWithResolverWithoutDefaultConstructor() {
resolveActiveProfiles(NoDefaultConstructorActiveProfilesResolverTest.class);
resolveActiveProfiles(NoDefaultConstructorActiveProfilesResolverTestCase.class);
}
/**
@@ -252,7 +252,7 @@ public class ContextLoaderUtilsActiveProfilesTests extends AbstractContextLoader
*/
@Test(expected = IllegalStateException.class)
public void resolveActiveProfilesWithResolverThatReturnsNull() {
resolveActiveProfiles(NullActiveProfilesResolverTest.class);
resolveActiveProfiles(NullActiveProfilesResolverTestCase.class);
}
@@ -299,38 +299,40 @@ public class ContextLoaderUtilsActiveProfilesTests extends AbstractContextLoader
}
@ActiveProfiles(resolver = NullActiveProfilesResolver.class)
private static class NullActiveProfilesResolverTest {
private static class NullActiveProfilesResolverTestCase {
}
@ActiveProfiles(resolver = NoDefaultConstructorActiveProfilesResolver.class)
private static class NoDefaultConstructorActiveProfilesResolverTest {
private static class NoDefaultConstructorActiveProfilesResolverTestCase {
}
@ActiveProfiles(resolver = FooActiveProfilesResolver.class)
private static class FooActiveProfilesResolverTest {
private static class FooActiveProfilesResolverTestCase {
}
private static class InheritedFooActiveProfilesResolverTest extends FooActiveProfilesResolverTest {
private static class InheritedFooActiveProfilesResolverTestCase extends FooActiveProfilesResolverTestCase {
}
@ActiveProfiles(resolver = BarActiveProfilesResolver.class)
private static class MergedInheritedFooActiveProfilesResolverTest extends InheritedFooActiveProfilesResolverTest {
private static class MergedInheritedFooActiveProfilesResolverTestCase extends
InheritedFooActiveProfilesResolverTestCase {
}
@ActiveProfiles(resolver = BarActiveProfilesResolver.class, inheritProfiles = false)
private static class OverridenInheritedFooActiveProfilesResolverTest extends InheritedFooActiveProfilesResolverTest {
private static class OverridenInheritedFooActiveProfilesResolverTestCase extends
InheritedFooActiveProfilesResolverTestCase {
}
@ActiveProfiles(resolver = BarActiveProfilesResolver.class, profiles = "conflict")
private static class ConflictingResolverAndProfilesTest {
private static class ConflictingResolverAndProfilesTestCase {
}
@ActiveProfiles(resolver = BarActiveProfilesResolver.class, value = "conflict")
private static class ConflictingResolverAndValueTest {
private static class ConflictingResolverAndValueTestCase {
}
@ActiveProfiles(profiles = "conflict", value = "conflict")
private static class ConflictingProfilesAndValueTest {
private static class ConflictingProfilesAndValueTestCase {
}
private static class FooActiveProfilesResolver implements ActiveProfilesResolver {

View File

@@ -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.
@@ -40,7 +40,7 @@ public class OverriddenMetaAnnotationAttributesTests {
@Test
public void contextConfigurationValue() throws Exception {
Class<MetaValueConfigTest> declaringClass = MetaValueConfigTest.class;
Class<MetaValueConfigTestCase> declaringClass = MetaValueConfigTestCase.class;
AnnotationDescriptor<ContextConfiguration> descriptor = findAnnotationDescriptor(declaringClass,
ContextConfiguration.class);
assertNotNull(descriptor);
@@ -56,7 +56,7 @@ public class OverriddenMetaAnnotationAttributesTests {
@Test
public void overriddenContextConfigurationValue() throws Exception {
Class<?> declaringClass = OverriddenMetaValueConfigTest.class;
Class<?> declaringClass = OverriddenMetaValueConfigTestCase.class;
AnnotationDescriptor<ContextConfiguration> descriptor = findAnnotationDescriptor(declaringClass,
ContextConfiguration.class);
assertNotNull(descriptor);
@@ -81,7 +81,7 @@ public class OverriddenMetaAnnotationAttributesTests {
@Test
public void contextConfigurationLocationsAndInheritLocations() throws Exception {
Class<MetaLocationsConfigTest> declaringClass = MetaLocationsConfigTest.class;
Class<MetaLocationsConfigTestCase> declaringClass = MetaLocationsConfigTestCase.class;
AnnotationDescriptor<ContextConfiguration> descriptor = findAnnotationDescriptor(declaringClass,
ContextConfiguration.class);
assertNotNull(descriptor);
@@ -98,7 +98,7 @@ public class OverriddenMetaAnnotationAttributesTests {
@Test
public void overriddenContextConfigurationLocationsAndInheritLocations() throws Exception {
Class<?> declaringClass = OverriddenMetaLocationsConfigTest.class;
Class<?> declaringClass = OverriddenMetaLocationsConfigTestCase.class;
AnnotationDescriptor<ContextConfiguration> descriptor = findAnnotationDescriptor(declaringClass,
ContextConfiguration.class);
assertNotNull(descriptor);
@@ -129,11 +129,11 @@ public class OverriddenMetaAnnotationAttributesTests {
}
@MetaValueConfig
public static class MetaValueConfigTest {
public static class MetaValueConfigTestCase {
}
@MetaValueConfig("bar.xml")
public static class OverriddenMetaValueConfigTest {
public static class OverriddenMetaValueConfigTestCase {
}
@ContextConfiguration(locations = "foo.xml", inheritLocations = false)
@@ -146,11 +146,11 @@ public class OverriddenMetaAnnotationAttributesTests {
}
@MetaLocationsConfig(inheritLocations = true)
static class MetaLocationsConfigTest {
static class MetaLocationsConfigTestCase {
}
@MetaLocationsConfig(locations = "bar.xml", inheritLocations = true)
static class OverriddenMetaLocationsConfigTest {
static class OverriddenMetaLocationsConfigTestCase {
}
}

View File

@@ -20,7 +20,7 @@ import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.test.context.junit4.aci.annotation.InitializerWithoutConfigFilesOrClassesTest;
import org.springframework.test.context.junit4.aci.annotation.InitializerWithoutConfigFilesOrClassesTests;
import org.springframework.test.context.junit4.aci.annotation.MergedInitializersAnnotationConfigTests;
import org.springframework.test.context.junit4.aci.annotation.MultipleInitializersAnnotationConfigTests;
import org.springframework.test.context.junit4.aci.annotation.OrderedInitializersAnnotationConfigTests;
@@ -45,7 +45,7 @@ import org.springframework.test.context.junit4.aci.xml.MultipleInitializersXmlCo
MergedInitializersAnnotationConfigTests.class,//
OverriddenInitializersAnnotationConfigTests.class,//
OrderedInitializersAnnotationConfigTests.class,//
InitializerWithoutConfigFilesOrClassesTest.class //
InitializerWithoutConfigFilesOrClassesTests.class //
})
public class AciTestSuite {
}

View File

@@ -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.
@@ -16,8 +16,6 @@
package org.springframework.test.context.junit4.aci.annotation;
import static org.junit.Assert.*;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -27,19 +25,21 @@ import org.springframework.context.annotation.AnnotatedBeanDefinitionReader;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.junit4.aci.annotation.InitializerWithoutConfigFilesOrClassesTest.EntireAppInitializer;
import org.springframework.test.context.junit4.aci.annotation.InitializerWithoutConfigFilesOrClassesTests.EntireAppInitializer;
import static org.junit.Assert.*;
/**
* Integration test that verifies support for {@link ApplicationContextInitializer
* ApplicationContextInitializers} in the TestContext framework when the test
* class declares neither XML configuration files nor annotated configuration classes.
*
* ApplicationContextInitializers} in the TestContext framework when the test class
* declares neither XML configuration files nor annotated configuration classes.
*
* @author Sam Brannen
* @since 3.2
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(initializers = EntireAppInitializer.class)
public class InitializerWithoutConfigFilesOrClassesTest {
public class InitializerWithoutConfigFilesOrClassesTests {
@Autowired
private String foo;

View File

@@ -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.
@@ -36,7 +36,7 @@ import static org.junit.Assert.*;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
@ActiveProfiles(resolver = ClassNameActiveProfilesResolver.class)
public class ClassNameActiveProfilesResolverTest {
public class ClassNameActiveProfilesResolverTests {
@Configuration
static class Config {

View File

@@ -33,10 +33,10 @@ import static org.junit.Assert.*;
*
* @author Sam Brannen
* @since 4.0
* @see WebTest
* @see WebTestStereotype
*/
@RunWith(SpringJUnit4ClassRunner.class)
@WebTest
@WebTestStereotype
public class MetaAnnotationConfigWacTests {
@Autowired

View File

@@ -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.
@@ -33,7 +33,7 @@ import org.springframework.test.context.ContextConfiguration;
@WebAppConfiguration
@ContextConfiguration
@Retention(RetentionPolicy.RUNTIME)
public @interface WebTest {
public @interface WebTestStereotype {
@Configuration
static class Config {