Create Test Suite in JUnit

Let’s learn, How can you create the Test Suite in JUnit. A test suite is the bundle of test cases or the group of test cases. In JUnit, we can create the Test Suite or run the test in batch.

For the Test Suite creation, we need to use two annotations of JUnit @Runwith and @SuiteClasses. These are used to run test cases together. This is very helpful if you have many test classes and you want to run them all together instead of running each test one at a time.

 

With the @RunWith annotation, we need to add suite.class in a parameter like this@RunWith(Suite.class) and in @SuiteClasses,  we need to pass the class name separated by the comma. We can add as many as we can Test classes with @SuiteClasses to add the Test Classes in the Test Suite.

 

Let’s see an example as in past we have created two Test classes FirstTestClass and SecondTestClass , we are going to create the third class TestSuiteClass and will run the both of the Test classes within the TestSuiteClass make these as a Test Suite.

Test Suite In Java

 

You can see both of the classes mentioned within the @SuiteClasses annotation are executed. So by this way you can create the Test Suite in JUnit and run the Test cases in the batch.

 

Selenium Tutorial:

If you liked this video, then please subscribe to our YouTube Channel for more video tutorials.

 

0 Comment

Leave a Reply