Usage of test suite in JUNIT4

Source: Internet
Author: User
The wizard for the new test suite in Eclipse, which looks like the current project, is for JUNIT3, and a lot of data on the web, the test suite is Junit3, and here's a quick overview of how the test suite in JUNIT4 is used.


One is similar to the Junit3 method:

public class TestSuite1 {The public
Static test suite () {
TestSuite suite = new TestSuite (' Test for Package1 ');

Suite.addtest (New Junit4testadapter (Test1.class));
Suite.addtest (New Junit4testadapter (Test2.class)); 
Suite.addtest (New Junit4testadapter (Test3.class));

Suite.addtest (New Junit4testadapter (Testsuite2.class));
return suite;
}
}

Junit3 is the direct suite.addtest (test1.class), JUNIT4 need to use Junit4testadapter to convert. Testsuite can also be added Testsuite, the same method, namely Suite.addtest (new Junit4testadapter (Testsuite2.class));

Another way to use annotations is to:

@RunWith (Suite.class)
@Suite. suiteclasses ({ 
test1.class, 
test2.class,
Test3.class,

Testsuite2.class
}) public
class TestSuite1 {
}




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.