What Is JUnit TestSuite?

Q

What Is JUnit TestSuite?

✍: FYICenter.com QA Team

A

JUnit TestSuite is a container class, junit.framework.TestSuite, used in JUnit 3.8 that allows you to group multiple test cases into a collection and run them together. TestSuite class is no longer supported in JUnit 4.4.

Each test runs in its own fixture so there can be no side effects among test runs. Here is an example:

import junit.framework.*;
// by FYICenter.com
public class RunTestSuite {
    public static void main(String[] a) {
        TestSuite suite = new TestSuite(MathTest.class);
	TestResult result = new TestResult();
        suite.run(result);
        System.out.println("Was it successful? "
            +result.wasSuccessful());
        System.out.println("How many tests were there? "
            +result.runCount());
    }
}

2008-03-04, 5697👍, 0💬