Search in sources :

Example 1 with TestSetup

use of junit.extensions.TestSetup 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 TestSetup

use of junit.extensions.TestSetup in project junit4 by junit-team.

the class ExtensionTest method testRunningErrorsInTestSetup.

public void testRunningErrorsInTestSetup() {
    TestCase failure = new TestCase("failure") {

        @Override
        public void runTest() {
            fail();
        }
    };
    TestCase error = new TestCase("error") {

        @Override
        public void runTest() {
            throw new Error();
        }
    };
    TestSuite suite = new TestSuite();
    suite.addTest(failure);
    suite.addTest(error);
    TestSetup wrapper = new TestSetup(suite);
    TestResult result = new TestResult();
    wrapper.run(result);
    assertEquals(1, result.failureCount());
    assertEquals(1, result.errorCount());
}
Also used : TestSetup(junit.extensions.TestSetup) TestSuite(junit.framework.TestSuite) TestCase(junit.framework.TestCase) TestResult(junit.framework.TestResult)

Example 3 with TestSetup

use of junit.extensions.TestSetup in project jmeter by apache.

the class TestHTTPMirrorThread method suite.

// We need to use a suite in order to preserve the server across test cases
// With JUnit4 we could use before/after class annotations
public static Test suite() {
    TestSetup setup = new TestSetup(new TestSuite(TestHTTPMirrorThread.class)) {

        private HttpMirrorServer httpServer;

        @Override
        protected void setUp() throws Exception {
            httpServer = startHttpMirror(HTTP_SERVER_PORT);
        }

        @Override
        protected void tearDown() throws Exception {
            // Shutdown the http server
            httpServer.stopServer();
            httpServer = null;
        }
    };
    return setup;
}
Also used : TestSetup(junit.extensions.TestSetup) TestSuite(junit.framework.TestSuite)

Example 4 with TestSetup

use of junit.extensions.TestSetup in project gradle by gradle.

the class SomeSuite method suite.

public static Test suite() {
    final TestSuite suite = new TestSuite();
    suite.addTestSuite(SomeTest1.class);
    suite.addTestSuite(SomeTest2.class);
    TestSetup wrappedSuite = new junit.extensions.TestSetup(suite) {

        protected void setUp() {
            System.out.println("stdout in TestSetup#setup");
            System.err.println("stderr in TestSetup#setup");
        }

        protected void tearDown() {
            System.out.println("stdout in TestSetup#teardown");
            System.err.println("stderr in TestSetup#teardown");
        }
    };
    return wrappedSuite;
}
Also used : TestSetup(junit.extensions.TestSetup) TestSuite(junit.framework.TestSuite)

Example 5 with TestSetup

use of junit.extensions.TestSetup in project junit4 by junit-team.

the class ExtensionTest method testSetupErrorInTestSetup.

public void testSetupErrorInTestSetup() {
    WasRun test = new WasRun();
    TestSetup wrapper = new TestSetup(test) {

        @SuppressWarnings("deprecation")
        @Override
        public void setUp() {
            fail();
        }
    };
    TestResult result = new TestResult();
    wrapper.run(result);
    assertTrue(!test.fWasRun);
    assertTrue(!result.wasSuccessful());
}
Also used : WasRun(junit.tests.WasRun) TestSetup(junit.extensions.TestSetup) TestResult(junit.framework.TestResult)

Aggregations

TestSetup (junit.extensions.TestSetup)7 TestSuite (junit.framework.TestSuite)5 TestResult (junit.framework.TestResult)3 TestCase (junit.framework.TestCase)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 FileOutputStream (java.io.FileOutputStream)1 OutputStream (java.io.OutputStream)1 WasRun (junit.tests.WasRun)1 Configuration (org.apache.hadoop.conf.Configuration)1 MiniDFSCluster (org.apache.hadoop.hdfs.MiniDFSCluster)1 HttpMirrorServer (org.apache.jmeter.protocol.http.control.HttpMirrorServer)1