Monday, 11 August 2014

Selenium : Creating Junit Test Suite - Step by Step



What is Test Suite?

A Test Suite is a grouping unit test cases together and running it. In JUnit, both @RunWith and @Suite annotations are used to run the suite test.
If you want to run multiple tests together, you should go for a Test Suite to organise the tests.

1. First create a package and write 2 Test cases. 
2.       To create a Test suite, Right Click on the package, Select Junit --> Test Suite. Click on Next. 

 

3. After clicking on Next another window will shop up with list of all the tests inside the package.

 

4. A Test suite with the name AllTests.java will be created.

 



5.The test suite contains 2 junit annotations added with name = @RunWith and @SuiteClasses. 



@RunWith annotation will references junit to run test in class and
@SuiteClasses describes classes included in that test suite.
  
6. When you run this test suite a junit , it will run both the test one by one and the result will be printed on the console.



No comments:

Post a Comment