Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipse-dev] Top 10 (slowest) Unit Test Suites ... plus proposal to run only subset of tests for Nightly (Head) builds

akurtakov <akurtakov@xxxxxxxxx> wrote:
> It might be perfect time to jump on the JUnit 4 wagon and start using
> @Before (per-test) and @BeforeClass (per-testsuite) setups. This has
> huge impact for tests with heavy setups.

Note that the equivalent in JUnit 3 is TestSetup, e.g.:

public class MyTest extends TestCase {
        static class MyTestSetup extends TestSetup {
                static int state;
                public MyTestSetup(Test test) {
                protected void setUp() throws Exception {
                        state = 42; // heavy set-up
                protected void tearDown() throws Exception {
                        state = 0; // heavy clean-up
        public static Test suite() {
                return new MyTestSetup(new TestSuite(MyTest.class));

        public void test1() throws Exception {
                 assertEquals(true, false);
        public void test2() throws Exception {
                assertEquals(42, MyTestSetup.state);

         * Hint: Special method called by Eclipse if you have
         * "Keep JUnit running after a test run when debugging" enabled
         * and then choose "context menu > Rerun" in the JUnit view.
        public static Test setUpTest(Test test) {
                return new MyTestSetup(test);


Back to the top