Is it better to use TestNG Suite Test than using JUnit Suite Test?

0 votes
Jun 11 in Selenium by Zaid
20 views

1 answer to this question.

0 votes

Hi Zaid, Suites are used to execute multiple tests together. Suites can be created using both TestNG and JUnit4. But, suites are more powerful in TestNG as it uses very different method for execution of tests. So, it is better to use TestNG Suite rather than using Junit Suite. TestNG can do more than bundle class testing, it can do bundle method testing as well. With TestNG unique “Grouping” concept, every method is tie to a group, it can categorize tests according to features. For eg.

In JUnit, the “@RunWith” and “@Suite” are use to run the suite test. The below class means both unit test “JunitTest1” and “JunitTest2” run together after JunitTest5 executed:

@RunWith(Suite.class)
@Suite.SuiteClasses({
        JunitTest1.class,
        JunitTest2.class
})
public class JunitTest5 {
}

While in TestNG, XML file is use to run the suite test. The below XML file means both unit test “TestNGTest1” and “TestNGTest2” will run it together:

<suite name="My test suite">
  <test name="testing">
    <classes>
       <class name="com.fsecure.demo.testng.TestNGTest1" />
       <class name="com.fsecure.demo.testng.TestNGTest2" />
    </classes>
  </test>
</suite>
answered Jun 11 by Anvi
• 10,310 points

Related Questions In Selenium

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

TestNG and Junit

No, testNG is better than JUnit. Here ...READ MORE

answered Jan 8 in Selenium by Nabarupa
60 views
0 votes
1 answer

What is the difference between JUnit and TestNG?

JUnit    TestNG It is opensource testing framework. It is ...READ MORE

answered Jan 17 in Selenium by Rishab
• 1,460 points
146 views
0 votes
1 answer

What are the advantages of TestNG over JUnit framework?

Hey Kimberly, TestNG has many advantages over ...READ MORE

answered Jun 11 in Selenium by Abha
• 16,440 points
27 views
0 votes
1 answer

What is TestNG and why it is used in selenium?

Hello @User, Talking about TestNG, it is an ...READ MORE

answered Dec 24, 2018 in Selenium by Shuvodip
68 views
0 votes
1 answer

Is it possible to do Database testing by using Selenium Webdriver?

Hey Kanika, Selenium Webdriver is limited to Testing Browser ...READ MORE

answered May 15 in Selenium by Anvi
• 10,310 points
38 views
0 votes
1 answer