God_Father
God_Father

Reputation: 599

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?

Upvotes: 5

Views: 15976

Answers (4)

Mandar Kale
Mandar Kale

Reputation: 337

You can very well create automated script with the amount selenium and Java knowledge you have. But now, if your manager asks you to run all of your testscript and publish report of pass fail to him. Very primitive way to do this, is add name of your test scripts in excel, get its result by running one by one in eclipse IDE or equivalent and update result in excel.

To avoid this, you can use testNG or junit. TestNG and junit are test framework. One part of automation is developing automation script, another is running it. Junit & TestNG helps in running the automated scripts. which includes, preparing test data, manage it, run tests, publish/store execution report, clear/delete testdata.

You can pick up the TestNG or junit knowledge easily for happy path scenarios. Need to put extra efforts in handling complex situations.

You will also come across terms like Jenkins or CI (Continuous Integration) along with this. Stay Enthusiastic. Its wonderful world of Automation framework.

Upvotes: 1

Mayur Shah
Mayur Shah

Reputation: 528

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

Upvotes: 4

Nathan Merrill
Nathan Merrill

Reputation: 8386

  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.

Upvotes: 6

BlackHatSamurai
BlackHatSamurai

Reputation: 23493

JUnit is the basic testing framework that Java uses. It relates to selenium in that if you are doing any testing and you wanted to write the tests with Java, you would use JUnit to write the tests, and hook into Selenium. The answer to your third question is hard to answer. JUnit is java based, so if you know Java, you'll be fine. Assuming that you have a basic understanding of programming, you should be fine.

TestNG is similar to JUnit, but it is not the 'defacto' test framework for Java.

Here are some links that might help:

http://testng.org/doc/index.html

http://junit.org/

Upvotes: 1

Related Questions