JAVA Batch Execution test cases

Source: Internet
Author: User

If multiple test cases are in different classes and you need to execute all the test cases at once, you can use the bulk execution test method in JUnit.

Method One

This is very simple and does not require an extra line of code, and Eclipse would have supported batch execution of tests in project or package units.
Case.
Right-click on the project--->run as--->run configurations.

Click "Search ..." Button.

Select the specified package under Engineering/engineering. Click "OK" to go back to the Run Configuration window and click the "Run" button to run all the test cases under the selected range.

The second Kind

This approach introduces the concept of a "test suite", and JUnit provides a way to run the test class in batches, called a test suite.
The test suite should be written in the following guidelines:

1. Create an empty class as the entrance to the test suite;
2. Use annotations Org.junit.runner.RunWith and org.junit.runners.Suite.SuitClasses to decorate this empty class
3. Pass the Org.junit.runners.Suite as a parameter to the annotation runwith to prompt JUnit to use the suite runner for such tests
Yes.
4. Make an array of the test classes that need to be put into this test suite as parameters for the annotation suiteclasses
5. Ensure that the empty class is decorated with public and that there are exposed constructors with no arguments

Note: suitclasses ({  Here contains the. class file for the class that needs to run the test case})
Below the test package (com.junit.test), create a test class that reads as follows:

 Package com.junit.test; Import Org.junit.runner.RunWith; Import Org.junit.runners.Suite; Import org.junit.runners.Suite.SuiteClasses; @RunWith (Suite. class ) @SuiteClasses ({testadd. class , TestSub. class ,})  Public class Testall {}

JAVA Batch Execution test cases

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.