Skip to content

Commit

Permalink
[hotfix] [tests] Improve TypeInfoTestCoverageTest
Browse files Browse the repository at this point in the history
  • Loading branch information
StephanEwen committed Nov 2, 2017
1 parent 3ff91be commit 6afd68b
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@
import org.apache.flink.util.TestLogger;

import org.junit.Test;

import org.reflections.Reflections;

import java.lang.reflect.Modifier;
import java.util.Set;
import java.util.stream.Collectors;

import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

/**
* Scans the class path for type information and checks if there is a test for it.
Expand All @@ -40,7 +42,9 @@ public void testTypeInfoTestCoverage() {
Reflections reflections = new Reflections("org.apache.flink");

Set<Class<? extends TypeInformation>> typeInfos = reflections.getSubTypesOf(TypeInformation.class);
Set<Class<? extends TypeInformationTestBase>> typeInfoTests = reflections.getSubTypesOf(TypeInformationTestBase.class);

Set<String> typeInfoTestNames = reflections.getSubTypesOf(TypeInformationTestBase.class)
.stream().map(Class::getName).collect(Collectors.toSet());

// check if a test exists for each type information
for (Class<? extends TypeInformation> typeInfo : typeInfos) {
Expand All @@ -54,13 +58,11 @@ public void testTypeInfoTestCoverage() {
typeInfo.getName().contains("queryablestate")) {
continue;
}
boolean found = false;
for (Class<? extends TypeInformationTestBase> typeInfoTest : typeInfoTests) {
if (typeInfoTest.getName().equals(typeInfo.getName() + "Test")) {
found = true;
}

final String testToFind = typeInfo.getName() + "Test";
if (!typeInfoTestNames.contains(testToFind)) {
fail("Could not find test '" + testToFind + "' that covers '" + typeInfo.getName() + "'.");
}
assertTrue("Could not find test that corresponds to " + typeInfo.getName(), found);
}
}
}

0 comments on commit 6afd68b

Please sign in to comment.