Logger.setFactory(TestLoggerFactory.getInstance());
}
- private static final Logger LOG = Logger.getInstance("#com.intellij.TestAll");
-
private TestCaseLoader myTestCaseLoader;
private long myStartTime = 0;
private final boolean myInterruptedByOutOfMemory = false;
public static final int MAX_FAILURE_TEST_COUNT = 150;
public int countTestCases() {
- List classes = myTestCaseLoader.getClasses();
+ List<Class> classes = myTestCaseLoader.getClasses();
int count = 0;
if (PlatformTestCase.ourTestThread != null) {
return PlatformTestCase.ourTestThread;
}
- else if (LightPlatformTestCase.ourTestThread != null) {
- return LightPlatformTestCase.ourTestThread;
- }
- else {
- return null;
- }
+ else return LightPlatformTestCase.ourTestThread;
}
private void addErrorMessage(TestResult testResult, String message) {
}
public void run(final TestResult testResult) {
- List classes = myTestCaseLoader.getClasses();
+ List<Class> classes = myTestCaseLoader.getClasses();
int totalTests = classes.size();
- for (final Object aClass : classes) {
- runNextTest(testResult, totalTests, (Class)aClass);
+ for (final Class aClass : classes) {
+ runNextTest(testResult, totalTests, aClass);
if (testResult.shouldStop()) break;
}
tryGc(10);
}
log("Number of test classes found: " + myTestCaseLoader.getClasses().size());
+ myTestCaseLoader.checkClassesExist();
}
private static void log(String message) {
import com.intellij.idea.Bombed;
import com.intellij.openapi.util.Comparing;
+import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.testFramework.PlatformTestUtil;
import com.intellij.testFramework.TestRunnerUtil;
private final TestClassesFilter myTestClassesFilter;
private final String myTestGroupName;
private final Set<String> blockedTests = new HashSet<String>();
+ private final String[] slowTestNames;
public TestCaseLoader(String classFilterName) {
InputStream excludedStream = getClass().getClassLoader().getResourceAsStream(classFilterName);
}
}
+ String[] names;
+ try {
+ InputStream stream = getClass().getClassLoader().getResourceAsStream("tests/slowTests.txt");
+ names = FileUtil.loadTextAndClose(new InputStreamReader(stream)).split("\\s");
+ }
+ catch (Exception e) {
+ // no luck
+ names = new String[0];
+ }
+ slowTestNames = names;
if (Comparing.equal(System.getProperty(FAST_TESTS_ONLY_FLAG), "true")) {
- BufferedReader reader =
- new BufferedReader(new InputStreamReader(getClass().getClassLoader().getResourceAsStream("tests/slowTests.txt")));
+ blockedTests.addAll(Arrays.asList(slowTestNames));
+ }
+ else {
+ checkClassesExist();
+ }
+ System.out.println("Using test group: [" + myTestGroupName +"]");
+ }
+
+ void checkClassesExist() {
+ String s = "";
+ for (String slowTestName : slowTestNames) {
+ if (slowTestName.trim().length() == 0) continue;
try {
- String testName;
- while ((testName = reader.readLine()) != null) {
- blockedTests.add(testName);
- }
+ Class.forName(slowTestName);
}
- catch (IOException e) {
- // No luck
- } finally {
- try {
- reader.close();
- }
- catch (IOException e) {
- // ignore
- }
+ catch (ClassNotFoundException e) {
+ s += "\n" + slowTestName;
}
}
- System.out.println("Using test group: [" + myTestGroupName + "]");
+ if (s.length() != 0) {
+ throw new RuntimeException("Tests in slowTests.txt which cannot be instantiated: "+s);
+ }
}
/*