Search in sources :

Example 1 with TestSuite

use of junit.framework.TestSuite in project hadoop by apache.

the class TestDataJoin method suite.

public static Test suite() {
    TestSetup setup = new TestSetup(new TestSuite(TestDataJoin.class)) {

        protected void setUp() throws Exception {
            Configuration conf = new Configuration();
            cluster = new MiniDFSCluster.Builder(conf).numDataNodes(2).build();
        }

        protected void tearDown() throws Exception {
            if (cluster != null) {
                cluster.shutdown();
            }
        }
    };
    return setup;
}
Also used : TestSetup(junit.extensions.TestSetup) MiniDFSCluster(org.apache.hadoop.hdfs.MiniDFSCluster) TestSuite(junit.framework.TestSuite) Configuration(org.apache.hadoop.conf.Configuration)

Example 2 with TestSuite

use of junit.framework.TestSuite in project android_frameworks_base by ParanoidAndroid.

the class InstrumentationTestRunner method onCreate.

@Override
public void onCreate(Bundle arguments) {
    super.onCreate(arguments);
    mArguments = arguments;
    // Apk paths used to search for test classes when using TestSuiteBuilders.
    String[] apkPaths = { getTargetContext().getPackageCodePath(), getContext().getPackageCodePath() };
    ClassPathPackageInfoSource.setApkPaths(apkPaths);
    Predicate<TestMethod> testSizePredicate = null;
    Predicate<TestMethod> testAnnotationPredicate = null;
    Predicate<TestMethod> testNotAnnotationPredicate = null;
    String testClassesArg = null;
    boolean logOnly = false;
    if (arguments != null) {
        // Test class name passed as an argument should override any meta-data declaration.
        testClassesArg = arguments.getString(ARGUMENT_TEST_CLASS);
        mDebug = getBooleanArgument(arguments, "debug");
        mJustCount = getBooleanArgument(arguments, "count");
        mSuiteAssignmentMode = getBooleanArgument(arguments, "suiteAssignment");
        mPackageOfTests = arguments.getString(ARGUMENT_TEST_PACKAGE);
        testSizePredicate = getSizePredicateFromArg(arguments.getString(ARGUMENT_TEST_SIZE_PREDICATE));
        testAnnotationPredicate = getAnnotationPredicate(arguments.getString(ARGUMENT_ANNOTATION));
        testNotAnnotationPredicate = getNotAnnotationPredicate(arguments.getString(ARGUMENT_NOT_ANNOTATION));
        logOnly = getBooleanArgument(arguments, ARGUMENT_LOG_ONLY);
        mCoverage = getBooleanArgument(arguments, "coverage");
        mCoverageFilePath = arguments.getString("coverageFile");
        try {
            // Accept either string or int
            Object delay = arguments.get(ARGUMENT_DELAY_MSEC);
            if (delay != null)
                mDelayMsec = Integer.parseInt(delay.toString());
        } catch (NumberFormatException e) {
            Log.e(LOG_TAG, "Invalid delay_msec parameter", e);
        }
    }
    TestSuiteBuilder testSuiteBuilder = new TestSuiteBuilder(getClass().getName(), getTargetContext().getClassLoader());
    if (testSizePredicate != null) {
        testSuiteBuilder.addRequirements(testSizePredicate);
    }
    if (testAnnotationPredicate != null) {
        testSuiteBuilder.addRequirements(testAnnotationPredicate);
    }
    if (testNotAnnotationPredicate != null) {
        testSuiteBuilder.addRequirements(testNotAnnotationPredicate);
    }
    if (testClassesArg == null) {
        if (mPackageOfTests != null) {
            testSuiteBuilder.includePackages(mPackageOfTests);
        } else {
            TestSuite testSuite = getTestSuite();
            if (testSuite != null) {
                testSuiteBuilder.addTestSuite(testSuite);
            } else {
                // no package or class bundle arguments were supplied, and no test suite
                // provided so add all tests in application
                testSuiteBuilder.includePackages("");
            }
        }
    } else {
        parseTestClasses(testClassesArg, testSuiteBuilder);
    }
    testSuiteBuilder.addRequirements(getBuilderRequirements());
    mTestRunner = getAndroidTestRunner();
    mTestRunner.setContext(getTargetContext());
    mTestRunner.setInstrumentation(this);
    mTestRunner.setSkipExecution(logOnly);
    mTestRunner.setTest(testSuiteBuilder.build());
    mTestCount = mTestRunner.getTestCases().size();
    if (mSuiteAssignmentMode) {
        mTestRunner.addTestListener(new SuiteAssignmentPrinter());
    } else {
        WatcherResultPrinter resultPrinter = new WatcherResultPrinter(mTestCount);
        mTestRunner.addTestListener(new TestPrinter("TestRunner", false));
        mTestRunner.addTestListener(resultPrinter);
        mTestRunner.setPerformanceResultsWriter(resultPrinter);
    }
    start();
}
Also used : TestSuiteBuilder(android.test.suitebuilder.TestSuiteBuilder) TestSuite(junit.framework.TestSuite) TestMethod(android.test.suitebuilder.TestMethod)

Example 3 with TestSuite

use of junit.framework.TestSuite in project android_frameworks_base by ParanoidAndroid.

the class TestSuiteBuilder method build.

/**
     * Call this method once you've configured your builder as desired.
     *
     * @return The suite containing the requested tests.
     */
public final TestSuite build() {
    rootSuite = new TestSuite(getSuiteName());
    // Keep track of current class so we know when to create a new sub-suite.
    currentClassname = null;
    try {
        for (TestMethod test : testGrouping.getTests()) {
            if (satisfiesAllPredicates(test)) {
                addTest(test);
            }
        }
        if (testCases.size() > 0) {
            for (TestCase testCase : testCases) {
                if (satisfiesAllPredicates(new TestMethod(testCase))) {
                    addTest(testCase);
                }
            }
        }
    } catch (Exception exception) {
        Log.i("TestSuiteBuilder", "Failed to create test.", exception);
        TestSuite suite = new TestSuite(getSuiteName());
        suite.addTest(new FailedToCreateTests(exception));
        return suite;
    }
    return rootSuite;
}
Also used : TestSuite(junit.framework.TestSuite) TestCase(junit.framework.TestCase) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 4 with TestSuite

use of junit.framework.TestSuite in project android_frameworks_base by ParanoidAndroid.

the class PowerTestRunner method getAllTests.

@Override
public TestSuite getAllTests() {
    TestSuite suite = new InstrumentationTestSuite(this);
    suite.addTestSuite(PowerMeasurement.class);
    return suite;
}
Also used : TestSuite(junit.framework.TestSuite) InstrumentationTestSuite(android.test.InstrumentationTestSuite) InstrumentationTestSuite(android.test.InstrumentationTestSuite)

Example 5 with TestSuite

use of junit.framework.TestSuite in project android_frameworks_base by ParanoidAndroid.

the class InstrumentationTestRunnerTest method testMultipleTestClass.

public void testMultipleTestClass() throws Exception {
    String classArg = PlaceHolderTest.class.getName() + "," + PlaceHolderTest2.class.getName();
    mInstrumentationTestRunner.onCreate(createBundle(InstrumentationTestRunner.ARGUMENT_TEST_CLASS, classArg));
    Test test = mStubAndroidTestRunner.getTest();
    assertContentsInOrder(ListTestCaseNames.getTestNames((TestSuite) test), new TestDescriptor(PlaceHolderTest.class.getName(), "testPlaceHolder"), new TestDescriptor(PlaceHolderTest2.class.getName(), "testPlaceHolder2"));
}
Also used : TestSuite(junit.framework.TestSuite) Test(junit.framework.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest) TestDescriptor(android.test.suitebuilder.ListTestCaseNames.TestDescriptor)

Aggregations

TestSuite (junit.framework.TestSuite)1380 InstrumentationTestSuite (android.test.InstrumentationTestSuite)100 Test (junit.framework.Test)63 GwtIncompatible (com.google.common.annotations.GwtIncompatible)54 JUnit4TestAdapter (junit.framework.JUnit4TestAdapter)50 TestCase (junit.framework.TestCase)48 Entry (java.util.Map.Entry)36 TestResult (junit.framework.TestResult)33 List (java.util.List)28 Set (java.util.Set)27 TestProjectSetup (org.eclipse.wst.jsdt.web.ui.tests.internal.TestProjectSetup)27 ArrayList (java.util.ArrayList)25 ListTestSuiteBuilder (com.google.common.collect.testing.ListTestSuiteBuilder)24 TestStringSetGenerator (com.google.common.collect.testing.TestStringSetGenerator)24 Map (java.util.Map)19 File (java.io.File)16 Method (java.lang.reflect.Method)16 HashSet (java.util.HashSet)13 Helpers.mapEntry (com.google.common.collect.testing.Helpers.mapEntry)12 TestStringMultisetGenerator (com.google.common.collect.testing.google.TestStringMultisetGenerator)12