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

0 votes
Jun 11, 2019 in Selenium by Zaid
609 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, 2019 by Anvi
• 14,150 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, 2019 in Selenium by Nabarupa
545 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, 2019 in Selenium by Rishab
• 1,490 points
3,372 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 12, 2019 in Selenium by Abha
• 28,140 points
6,522 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
1,115 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 16, 2019 in Selenium by Anvi
• 14,150 points
550 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP