diff --git a/js/js.tests/test/org/jetbrains/k2js/test/BasicTest.java b/js/js.tests/test/org/jetbrains/k2js/test/BasicTest.java index c96c807c5d5..f968aad4790 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/BasicTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/BasicTest.java @@ -56,7 +56,7 @@ public abstract class BasicTest extends TestWithEnvironment { } @Override - protected void setUp() throws Exception { + public void setUp() throws Exception { super.setUp(); if (!shouldCreateOut()) { return; @@ -114,7 +114,7 @@ public abstract class BasicTest extends TestWithEnvironment { } @NotNull - private String getInputPath() { + public String getInputPath() { return pathToTestFiles() + casesDirectoryName(); } diff --git a/js/js.tests/test/org/jetbrains/k2js/test/semantics/ExamplesTest.java b/js/js.tests/test/org/jetbrains/k2js/test/semantics/ExamplesTest.java index 43acc444b4b..7a937342b64 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/semantics/ExamplesTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/semantics/ExamplesTest.java @@ -16,17 +16,20 @@ package org.jetbrains.k2js.test.semantics; -import com.intellij.testFramework.UsefulTestCase; import junit.framework.Test; import org.jetbrains.annotations.NotNull; import org.jetbrains.k2js.test.SingleFileTranslationTest; import org.jetbrains.k2js.test.utils.SuiteBuilder; @SuppressWarnings("JUnitTestCaseWithNoTests") -public final class ExamplesTest extends UsefulTestCase { +public final class ExamplesTest extends SingleFileTranslationTest { + + public ExamplesTest() { + super("examples/"); + } public static Test suite() throws Exception { - return SuiteBuilder.suiteForDirectory("examples/", new SuiteBuilder.Tester() { + return SuiteBuilder.suiteForTestClass(new ExamplesTest(), new SuiteBuilder.Tester() { @Override public void performTest(@NotNull SingleFileTranslationTest test, @NotNull String filename) throws Exception { test.runFunctionOutputTest(filename, "Anonymous", "box", "OK"); diff --git a/js/js.tests/test/org/jetbrains/k2js/test/semantics/SimpleTest.java b/js/js.tests/test/org/jetbrains/k2js/test/semantics/SimpleTest.java index 7b7282de0d5..a7c0f6eab9b 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/semantics/SimpleTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/semantics/SimpleTest.java @@ -16,7 +16,6 @@ package org.jetbrains.k2js.test.semantics; -import com.intellij.testFramework.UsefulTestCase; import junit.framework.Test; import org.jetbrains.annotations.NotNull; import org.jetbrains.k2js.test.SingleFileTranslationTest; @@ -26,9 +25,14 @@ import org.jetbrains.k2js.test.utils.SuiteBuilder; * @author Pavel Talanov */ @SuppressWarnings("JUnitTestCaseWithNoTests") -public final class SimpleTest extends UsefulTestCase { +public final class SimpleTest extends SingleFileTranslationTest { + + public SimpleTest() { + super("simple/"); + } + public static Test suite() throws Exception { - return SuiteBuilder.suiteForDirectory("simple/", new SuiteBuilder.Tester() { + return SuiteBuilder.suiteForTestClass(new SimpleTest(), new SuiteBuilder.Tester() { @Override public void performTest(@NotNull SingleFileTranslationTest test, @NotNull String filename) throws Exception { test.checkFooBoxIsTrue(filename); diff --git a/js/js.tests/test/org/jetbrains/k2js/test/utils/SuiteBuilder.java b/js/js.tests/test/org/jetbrains/k2js/test/utils/SuiteBuilder.java index fe352b0fb3b..c92fa5cb1bb 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/utils/SuiteBuilder.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/utils/SuiteBuilder.java @@ -26,46 +26,47 @@ import org.jetbrains.k2js.test.semantics.TranslatorTestCaseBuilder; * @author Pavel Talanov */ @SuppressWarnings("JUnitTestCaseWithNoTests") -public abstract class SuiteBuilder extends SingleFileTranslationTest { - - private SuiteBuilder(@NotNull String pathToMain) { - super(pathToMain); - } +public abstract class SuiteBuilder { public interface Tester { void performTest(@NotNull SingleFileTranslationTest test, @NotNull String filename) throws Exception; } @SuppressWarnings("JUnitTestCaseWithNonTrivialConstructors") - private class SingleFileTest extends UsefulTestCase { - - public SingleFileTest(@NotNull String name, @NotNull Tester tester) { - setName(name); - this.tester = tester; - this.name = name; - } + private static class SingleFileTest extends UsefulTestCase { @NotNull private final Tester tester; + @NotNull private final String name; + @NotNull + private final SingleFileTranslationTest actualTest; + + public SingleFileTest(@NotNull SingleFileTranslationTest actualTest, @NotNull String name, @NotNull Tester tester) { + setName(name); + this.tester = tester; + this.name = name; + this.actualTest = actualTest; + } + public void runTest() throws Exception { - tester.performTest(SuiteBuilder.this, name); + tester.performTest(actualTest, name); } } - public static Test suiteForDirectory(@NotNull final String main, @NotNull final SuiteBuilder.Tester testMethod) throws Exception { - final SuiteBuilder singleFileTest = new SuiteBuilder(main) { - }; - singleFileTest.setUp(); - return TranslatorTestCaseBuilder.suiteForDirectory(pathToTestFilesRoot() + main + casesDirectoryName(), + public static Test suiteForTestClass(@NotNull final SingleFileTranslationTest actualTest, + @NotNull final SuiteBuilder.Tester testMethod) throws Exception { + //TODO: tearDown not called + actualTest.setUp(); + return TranslatorTestCaseBuilder.suiteForDirectory(actualTest.getInputPath(), true, new TranslatorTestCaseBuilder.NamedTestFactory() { @NotNull @Override public Test createTest(@NotNull String name) { - return singleFileTest.new SingleFileTest(name, testMethod); + return new SingleFileTest(actualTest, name, testMethod); } }); }