How to generate reports using junit selenium Web Driver

Ant is a open source build tool, used to compile the source code, creating the build artifacts such as JAR, WAR, and EAR files.  Some of the other usage of ANT is to run unit tests, application deployment on containers such as Tomcat, WebSphere,GlassFish.. etc, and to run Selenium Automation Tests.Ant is a very userful build tool ,is very much extensible.  Varies open source Ant libraries available which has to be downloaded, unzip, and copy (JAR file) into the Ant's "lib" folder.  Once the library file is copied, then we can utilize the "Tasks" in the Ant's build.xml file. 
Ant contribute library etc are the best examples for such libraries.

Lets create a new project in Eclipse and generate a build.xml file to execute the Java files of project
In this example we are going to generate the junit reports.

  1. Create new project – Sample
  2. Create a new package (under src) – com.example.Sample
  3. create new Java class – SampleTest.java
  4. Write some login code or any thing for testing purpose


My Sample Code of SampleTest.java








































Lets create the Junit reports

1.Select Project name
2.Right Click on Project name
3.Export-- Select AntBuildfiles
4.Click on Next
5.Select Project as a default project is selected
6.build.xml name is also entered as a default 
Note:If you are already created build.xml for another project then need to mention another name while creating new xml
7.Click on Finish button
8.Now go to Window--Preferences tab
9.Select Ant -- Runtime
10.Select Global Entries
11.Click on Add external jar
12.Browse to junit.jar file in Eclipse -- Plugins --org.junit_4.10.0.v4_10_0_v20120426-0900(I am using this)--junit.jar
13.Click on OK
14.Now refresh the project you will see new build.xml file will generate automatically
15.Just right click on build.xml file and Run As--Ant Build
16.You need to select Order of the test to run
17.Click on OK 

Whenever you run a tests will generate test results,placed in junit output directory. These results are formatted into an HTML report by the junitreport target ,stored in output directory.







Post a Comment

1 Comments

  1. Pretty section of content. I just stumbled upon your blog and in accession capital
    to assert that I get in fact enjoyed account your blog posts.
    Any way I'll be subscribing to your feeds and even I achievement you
    access consistently rapidly.

    ReplyDelete