Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are TestNG and JUnit frameworks in Selenium

I have started learning selenium through YouTube videos and online tutorial..

I now have knowledge on Creating Classes, Interfaces, Objects, Inheritance, Arrays, Loops in Java.

As far as Selenium is concerned, I am able automate directly in Selenium using Java language by identifying each elements using Firebug/Firepath tool.

But I constantly hear about TestNG and JUnit frameworks...

  1. What are these?
  2. How are they related to selenium?
  3. Is it difficult to pick them up with the amount of knowledge I currently possess?
like image 660
God_Father Avatar asked Oct 11 '13 18:10

God_Father


People also ask

What is JUnit and TestNG in Selenium?

JUnit is a framework that is open-source and may be used to write and trigger tests. TestNG is a Java-based framework that provides an improved way to run tests. Supports Annotation. Advanced annotation is not supported.

What is TestNG framework in Selenium?

What is TestNG in Selenium? TestNG is an open-source testing framework where NG stands for 'Next Generation. ' It is architected to simplify a broad range of testing needs starting from unit testing to integrated system testing. Initially, both JUnit and TestNG were designed solely for unit testing.

What is JUnit framework in Selenium?

JUnit is an open-source framework for performing unit testing of Java-based web apps. You can also use it with Selenium WebDriver to automate the testing of your web applications. In addition, with JUnit, you can create test cases in a more structured and better format.

What kind of framework is JUnit?

JUnit is a unit testing framework for the Java programming language. JUnit has been important in the development of test-driven development, and is one of a family of unit testing frameworks which is collectively known as xUnit that originated with SUnit.


2 Answers

  1. They are tools to help you organize your tests. You can define what you want to run before/after tests, you can group your tests, and reporting on them is made easier.

  2. It is usually mentioned with Selenium because Selenium is a common testing tool. The two work together well, but they are completely separate. (Selenium connects you to your browser, TestNG/JUnit organizes the tests)

  3. Yes. You should be able to pick them up. They are designed to be fairly easy to learn.

like image 170
Nathan Merrill Avatar answered Nov 14 '22 21:11

Nathan Merrill


JUnit is shipped with most of the IDEs such as Eclipse and NetBeans. There are many testing frameworks being developed using JUnit.

TestNG is an open source framework. It supports parametrization, data driven testing, parallel execution. JUnit is not much flexible for these.

I prefer TestNG over JUnit. I have developed open source testing framework using TestNG for Selenium. You may want to have a look at it.

https://github.com/selenium-webdriver-software-testing/kspl-selenium-helper

like image 25
Mayur Shah Avatar answered Nov 14 '22 21:11

Mayur Shah