Showing posts with label Junit with webdriver. Show all posts
Showing posts with label Junit with webdriver. Show all posts

We have already learn how to configure eclipse for webdriver, Creating new project, new package and then adding new class in my one of the previous post. In that post you can see how to add external jars of webdriver software testing tool in eclipse to install junit in eclipse. Also you can view how to run your first webdriver test in eclipse for better understanding.

As you know, JUnit and TestNG are very popular unit testing frameworks for java software developers and we can use them in our webdriver test execution for any software web application. Till now, I have described all WEBDRIVER TUTORIALS with junit framework. Many peoples are asking me to describe the similarities and difference between JUnit and TestNG Framework. First of all let me give you few similarities of JUnit and TestNG frameworks and then I will tell you difference between both of them.

(Note : Bellow given similarities and differences are based on JUnit 4 version.)

Similarities Between JUnit and TestNG
  1. We can create test suite in JUnit and TestNG both frameworks.
  2. Timeout Test Is possible very easily in both the frameworks.
  3. We can ignore specific test case execution of software web application from suite in both the frameworks.
  4. It is possible to create expected exception test for software web application in both the frameworks.
  5. Annotations - Few annotations are similar in both frameworks suite like @Test, @BeforeClass, @AfterClass. JUnit's Annotations @Before and @After are similar to TestNG's @BeforeMethod and @AfterMethod annotations.
Difference Between JUnit and TestNG
  1. In TestNG, Parameterized test configuration is very easy while It is very hard to configure Parameterized test in JUnit.
  2. TestNG support group test but it is not supported in JUnit.
  3. TestNG has a feature to configure dependency test. Dependency test configuration for software web application is not possible in JUnit.
  4. TestNG support @BeforeTest, @AfterTest, @BeforeSuite, @AfterSuite, @BeforeGroups, @AfterGroups which are not supported in JUnit.
  5. Test prioritization, Parallel testing is possible in TestNG. It is not supported by JUnit.
  6. View more features of TestNG @ THIS LINK .
If you knows more differences or features then you can post it by commenting bellow.

Sometimes you need to set time out for your webdriver test or you need to set expected exception condition for your test. Supposing you have written test for one module and you wants to set timeout for your test. Here timeout means allowed maximum time to complete full test. Same way, You are expecting some exception during your webdriver test execution and that exception is acceptable.If you are using junit framework for your webdriver test then you can do it very easily. We have seen example of - how to Ignore specific webdriver test using junit's @Ignore annotation in THIS POST. Now let me describe how to write timeout test and exception test in junit with examples.

Many readers are asking me the difference between JUnit annotations @Before VS @BeforeClass and @After VS @AfterClass in webdriver software automation test. If you have read my JUNIT ANNOTATIONS POST, I have clearly described difference between @Before and @BeforeClass annotations and @After and @AfterClass annotations in bold text. Now let me describe once more and then we will look at practical example for both of them to use them in software automation test.

As described in my previous post, We can create junit test suite to execute multiple test cases from one place. See example of my previous post. junittest2 class have two @Test methods. Now If I wants to exclude/Ignore 1st @Test method from execution and wants to execute only 2nd @Test method then how can I do It? Ignoring specific test in junit test is very easy.

If you are planning to perform regression testing of any software web application using webdriver software testing then obviously there will be multiple test cases or test classes under your webdriver project. Example - There are 2 junit test cases of software web application under your project's package. Now if you wants to run both of them then how will you do it? Simple and easy solution is creating JUnit test suite. If your project has more than 2 test cases of software web application then you can create test suite for all those test cases to run all test cases from one place.

We have seen how to configure system and eclipse in configuration part 1 and configuration part 2 posts to generate Selenium webdriver HTML test report. Now we have a test case and build.xml file in our project tree. Let me describe you few steps of configuring and running build.xml file in eclipse. Now follow the bellow given build.xml file configuration steps to generate HTML report

Webdriver test result generation is very important and essential part of automation testing and for that you need to configure your eclipse accordingly. Before eclipse and ant configuration, you need to configure your system as described in Part - 1. Now let me describe you the steps of eclipse configuration to generate web driver test execution report using JUnit. Perform bellow given steps.

Many people facing issues in JUnit report generation configuration using ant and eclipse. If every thing is not setup properly then it will give you one or another error and you will be not able to generate JUnit software test case execution report for your webdriver test case. Let me describe you few system configuration steps in this post and eclipse configuration steps in my next post to generate JUnit test execution report very easily and without any error.

Unit testing framework JUnit has many annotations to control the flow and activity of code execution of selenium webdriver software test cases. You must need to insert JUnit annotation inside the java code to execute your software test case as junit test case. You can look in my previous post where i have used JUnit @Test annotation before software test method. Let me describe you mostly used 3 JUnit Annotations with example. You can view more details on JUnit at http://junit.org/.

We have already discussed about how to download and install junit in eclipse to run webdriver automation software test in my previous post. Please note that you need to add junit jar file only if it is not available in webdriver software testing tool's jar file folder. If it is already there with webdriver jar file folder then you not need to do anything to create and run junit test. Now let me describe you how to create webdriver test case using junit.