Google+

283. Introduction to JUnit








JUnit is a testing Framework for the Java Programming Language.

In order to Run a Selenium WebDriver Tests using JUnit, we have to perform the following thing first:
  • We have to use JUnit annotations in our Selenium WebDriver Tests

What are JUnit Annotations?

JUnit has before and after Annotations for:
  • Method
  • Class
Other Testing Frameworks ?

TestNG is an another testing Framework which can be used as an alternative to JUnit testing Framework and is also more powerful and has advantages over JUnit testing Framework.

JUnit is easy to use in Eclipse IDE and it comes by default with Eclipse IDE (i.e. No need of Installing JUnit separately if you have installed Eclipse IDE). Where as in order to use TestNG, we've to install it separately in Eclipse IDE (i.e. It wont come by default with Eclipse IDE).

As JUnit testing Framework is simple and easy to use. Hence I will be using JUnit testing Framework to explain the Selenium WebDriver tests and there after will introduce you to the TestNG framework when the time comes.

JUnit Annotations:

Out of all the JUnit Annotations we are going to use only the following five annotations in our Selenium Automation Tests:
  1. @Test
  2. @Before
  3. @After
  4. @BeforeClass
  5. @AfterClass

I will explain the above listed JUnit annotations by using them in the Selenium WebDriver automation tests.

And also its not required to learn JUnit testing Framework in depth, as we will any way move ourselves to TestNG testing Framework in future. So don't learn other things regarding JUnit testing Framework that are not mentioned in my posts.








Please comment below to feedback or ask questions.

Using JUnit annotation in our Selenium WebDriver Tests   will be explained in the next post.


 


No comments:

Blog Index