TestNG Tutorial
Introduction to TestNG Configuration and set up of TestNG project Simple TestNG project in IntelliJ IDEA TestNG annotations Assertions in TestNG Difference between assertEquals and assertSame Ignoring the tests in TestNG Grouping the tests timeOut tests in TestNG Exception tests in TestNG dependsOnMethods dependsOnGroups Hard and Soft dependencies Passing parameters using XML file Passing parameters using Data providers Dynamic Data Providers group-by-instances attribute in TestNG XML suite file Test priorities in TestNG invocationCount in TestNG Executing Selenium tests using TestNG Executing TestNG tests using main method Executing JUnit tests from within TestNG Running tests in Parallel in TestNG Executing only failed tests in TestNG TestNG integration with Maven TestNG integration with Gradle Reporter class in TestNG TestNG Reports Execution Listener Test Listener Comparison between JUnit and TestNGComparison of junit with testng
JUnit is the oldest unit testing framework. TestNG came in the industry much later after JUnit. Here are the major difference between JUnit and TestNG frameworks.- JUnit tests can not be executed in specific order. In TestNG, we can execute the tests in desired order.
- before and after group hooks are available in TestNG.
- BeforeSuite and AfterSuite hooks are available in TestNG. In JUnit we do not run tests using suite XML file So we do not have before and after suite hooks.
- In TestNG, tests can depend on other tests. In JUnit, we do not have such feature.
- JUnit does not create any test execution report. TestNG creates HTML report which includes details like which test classes were executed, which tests failed, how much time was taken for test execution
- We can run failed only tests in TestNG using failed-testNG.xml file in output directory. In JUnit, we can not run failed only tests.
- We can run junit tests from TestNG but not vice versa
- We can put @Test annotation at class level in TestNG but not in JUnit
Web development and Automation testing
solutions delivered!!