Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is TestSuite?

I am relatively new to Java and new to JUnit testing. It's absolutely clear to me what the Test class uis, but the TestSuite class confuses me. Can someone explain me what TestSuite is for?

like image 960
Иван Бишевац Avatar asked Aug 30 '11 21:08

Иван Бишевац


3 Answers

Its a collection of tests. It allows you to run such a collection as a group.

Example from the first link I found with google.

import junit.framework.Test;
import junit.framework.TestSuite;

public class EcommerceTestSuite {

    public static Test suite() {

        TestSuite suite = new TestSuite();

        //
        // The ShoppingCartTest we created above.
        //
        suite.addTestSuite(ShoppingCartTest.class);

        //
        // Another example test suite of tests.
        // 
        suite.addTest(CreditCardTestSuite.suite());

        //
        // Add more tests here
        //

        return suite;
    }

    /**
     * Runs the test suite using the textual runner.
     */
    public static void main(String[] args) {
        junit.textui.TestRunner.run(suite());
    }
}
like image 69
Peter Lawrey Avatar answered Oct 05 '22 05:10

Peter Lawrey


It is basically a group of tests that you (or someone) define once which you can run with the click of a button. The tests are automatically run and "marked", and if any test fails you are informed of details.

like image 33
WaelJ Avatar answered Oct 05 '22 05:10

WaelJ


there are some good definitions here: http://xunitpatterns.com/Testcase%20Class.html

like image 39
Ray Tayek Avatar answered Oct 05 '22 07:10

Ray Tayek