Use separate test methods instead of generated suit

This commit is contained in:
Nikolay Krasko
2012-09-07 15:11:55 +04:00
parent cd5521d6dc
commit 4376c7a87c
2 changed files with 12 additions and 51 deletions
@@ -22,10 +22,6 @@ import com.intellij.psi.PsiPolyVariantReference;
import com.intellij.psi.PsiReference; import com.intellij.psi.PsiReference;
import com.intellij.psi.ResolveResult; import com.intellij.psi.ResolveResult;
import com.intellij.testFramework.LightCodeInsightTestCase; import com.intellij.testFramework.LightCodeInsightTestCase;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.JetTestCaseBuilder;
import org.jetbrains.jet.plugin.PluginTestCaseBase; import org.jetbrains.jet.plugin.PluginTestCaseBase;
import java.io.File; import java.io.File;
@@ -34,41 +30,15 @@ import java.io.File;
* @author Nikolay Krasko * @author Nikolay Krasko
*/ */
public class ResolveBaseTest extends LightCodeInsightTestCase { public class ResolveBaseTest extends LightCodeInsightTestCase {
public void testMultiResolve() throws Exception {
private final String myPath; doMultiResolveTest();
private final String myName;
protected ResolveBaseTest(@NotNull String path, @NotNull String name) {
myPath = path;
myName = name;
// Set name explicitly because otherwise there will be "TestCase.fName cannot be null"
setName("testResolve");
} }
@Override public void testSeveralOverrides() throws Exception {
protected Sdk getProjectJDK() { doMultiResolveTest();
return PluginTestCaseBase.jdkFromIdeaHome();
} }
@Override protected void doMultiResolveTest() throws Exception {
protected String getTestDataPath() {
return new File(PluginTestCaseBase.getTestDataPathBase(), myPath).getPath() +
File.separator;
}
@NotNull
@Override
public String getName() {
return "test" + myName;
}
public void testResolve() throws Exception {
doTest();
}
// TODO: Currently this test is only for KT-763 bug - it should be extended to framework for testing references
protected void doTest() throws Exception {
final String testName = getTestName(false); final String testName = getTestName(false);
configureByFile(testName + ".kt"); configureByFile(testName + ".kt");
@@ -87,22 +57,13 @@ public class ResolveBaseTest extends LightCodeInsightTestCase {
assertTrue("Nothing resolved by reference '" + psiReference.getElement().getText() + "'.", element != null || results.length > 0); assertTrue("Nothing resolved by reference '" + psiReference.getElement().getText() + "'.", element != null || results.length > 0);
} }
@NotNull @Override
public static TestSuite suite() { protected Sdk getProjectJDK() {
TestSuite suite = new TestSuite(); return PluginTestCaseBase.jdkFromIdeaHome();
}
JetTestCaseBuilder.appendTestsInDirectory( @Override
PluginTestCaseBase.getTestDataPathBase(), "/resolve/", false, protected String getTestDataPath() {
JetTestCaseBuilder.kotlinFilter, new JetTestCaseBuilder.NamedTestFactory() { return new File(PluginTestCaseBase.getTestDataPathBase(), "/resolve/").getPath() + File.separator;
@NotNull
@Override
public Test createTest(@NotNull String dataPath, @NotNull String name, @NotNull File file) {
return new ResolveBaseTest(dataPath, name);
}
}, suite);
return suite;
} }
} }