Merge pull request #12625 from rmuir/git_sucks

NamingConventionTests should test subclasses of ESIntegTestCase end with IT
This commit is contained in:
Robert Muir 2015-08-03 21:57:14 -04:00
commit 3b7316fb8d
4 changed files with 14 additions and 4 deletions

View File

@ -26,6 +26,7 @@ import junit.framework.TestCase;
import org.apache.lucene.util.LuceneTestCase;
import org.elasticsearch.common.SuppressForbidden;
import org.elasticsearch.common.io.PathUtils;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.ESTokenStreamTestCase;
import org.junit.Ignore;
@ -51,6 +52,7 @@ public class NamingConventionTests extends ESTestCase {
final Set<Class> notImplementing = new HashSet<>();
final Set<Class> pureUnitTest = new HashSet<>();
final Set<Class> missingSuffix = new HashSet<>();
final Set<Class> integTestsInDisguise = new HashSet<>();
String[] packages = {"org.elasticsearch", "org.apache.lucene"};
for (final String packageName : packages) {
final String path = "/" + packageName.replace('.', '/');
@ -76,12 +78,19 @@ public class NamingConventionTests extends ESTestCase {
Class<?> clazz = loadClass(filename);
if (Modifier.isAbstract(clazz.getModifiers()) == false && Modifier.isInterface(clazz.getModifiers()) == false) {
if (clazz.getName().endsWith("Tests") ||
clazz.getName().endsWith("IT") ||
clazz.getName().endsWith("Test")) { // don't worry about the ones that match the pattern
if (ESIntegTestCase.class.isAssignableFrom(clazz)) {
integTestsInDisguise.add(clazz);
}
if (isTestCase(clazz) == false) {
notImplementing.add(clazz);
}
} else if (clazz.getName().endsWith("IT")) {
if (isTestCase(clazz) == false) {
notImplementing.add(clazz);
}
// otherwise fine
} else if (isTestCase(clazz)) {
missingSuffix.add(clazz);
} else if (junit.framework.Test.class.isAssignableFrom(clazz) || hasTestAnnotation(clazz)) {
@ -151,6 +160,7 @@ public class NamingConventionTests extends ESTestCase {
pureUnitTest.isEmpty());
assertTrue("Classes ending with Test|Tests] must subclass [" + classesToSubclass +"] " + notImplementing.toString(),
notImplementing.isEmpty());
assertTrue("Subclasses of ESIntegTestCase should end with IT as they are integration tests: " + integTestsInDisguise, integTestsInDisguise.isEmpty());
}
/*

View File

@ -36,7 +36,7 @@ import static org.hamcrest.Matchers.*;
*
*/
@ClusterScope(scope= Scope.TEST, numDataNodes =0)
public class SimpleNodesInfoTests extends PluginTestCase {
public class SimpleNodesInfoIT extends PluginTestCase {
static final class Fields {
static final String SITE_PLUGIN = "dummy";

View File

@ -49,7 +49,7 @@ import java.util.concurrent.*;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.greaterThan;
public class BlobStoreFormatTests extends AbstractSnapshotIntegTestCase {
public class BlobStoreFormatIT extends AbstractSnapshotIntegTestCase {
private static final ParseFieldMatcher parseFieldMatcher = new ParseFieldMatcher(Settings.EMPTY);

View File

@ -48,7 +48,7 @@ import static org.hamcrest.Matchers.notNullValue;
/**
*/
@ESIntegTestCase.ClusterScope(minNumDataNodes = 2)
public class RepositoriesTests extends AbstractSnapshotIntegTestCase {
public class RepositoriesIT extends AbstractSnapshotIntegTestCase {
@Test
public void testRepositoryCreation() throws Exception {