Reports are crucial for any tests carried out.
Steps to configure and generate the test result from java eclipse using Ant:
this post is for users who have already familiar with java and eclipse.
Generating the ANT build:
Right click on the project and
select Export --> Ant Buildfiles.-->Next-->Select the project-->Finish.
Configuring jar:
Select Windows menu-->Preference -->Global Entries -->Add External JARs-->Select the folder where the eclipse is installed. eclipse -->Plugin -->Currently its located in "org.junit_4.8.1.v4_8_1_v20100427-1100"-->"junit.jar"-->OK.
Run the Ant Build:
Steps to configure and generate the test result from java eclipse using Ant:
this post is for users who have already familiar with java and eclipse.
Generating the ANT build:
Right click on the project and
select Export --> Ant Buildfiles.-->Next-->Select the project-->Finish.
Configuring jar:
Select Windows menu-->Preference -->Global Entries -->Add External JARs-->Select the folder where the eclipse is installed. eclipse -->Plugin -->Currently its located in "org.junit_4.8.1.v4_8_1_v20100427-1100"-->"junit.jar"-->OK.
Run the Ant Build:
Create a folder "junit" in side the project folder.
Right click on the AntBuildfile-->RunAs -->AntBuild
Return to java project and run as junit test.
End of test run you will find the test result in a html file named as index.html it will be stored inside the junit folder.
Hello Sir,
ReplyDeleteI followed all the steps provided here.
I ran the AntBuild and it was successful. Then i ran the project but i don't see any index.html file under the junit folder.
Can you help?
I get the result now. But is there a way i can view all the assertions those have passed and failed. Because this result just pass or fail a entire function not individual checks.
ReplyDeleteI followed the steps too but cant see result . Can you tell me how you were able to get file in junit folder. Mine is empty.
Delete@Pokhriyal
DeleteCan you let us know what are your settings ??
Nayak how did you the results. my junit folder is blank. please be advice.
DeleteThanks, this was quite helpful. I'm using Eclipse Helios. I added some changes/details to your description which do apply at least for Helios:
ReplyDeleteGenerating the ANT build:
Right click on the project and select:
Export
-> General -> Ant Buildfiles -> Next
-> Select the project (is already selected)
-> Finish.
Now "build.xml" is generated in the project folder
Configuring JUnit.jar:
This step wasn't necessary for me, however here is where you could add the "junit.jar" in case you have to:
Select:
Windows menu
-> Preferences
-> Ant -> Runtime -> Global Entries
-> Add External JARs
-> in Eclipse install directory: "eclipse/plugins/org.junit_4.8.1.v4_8_1_v20100427-1100/junit.jar"
-> ok
Run the Ant Build:
Create a folder "junit" inside of the project folder.
Right click on the "build.xml"
-> RunAs -> AntBuild...
-> check all single JUnit test classes and the junitreport entry
-> Run
Right click the "junit" directory and select Refresh in the context menu (or press F5).
You will find the test results in "junit".
Open "junit/index.html".
(Running the tests "as JUnit Test" is not necessary)
I did everything that is said here.
ReplyDeleteAm using Eclipse + TestNG.
Running as AntBuild says "Build Successfull"
But when I run TestNG. The JUNIT folder is still empty.
Please help.
It would be ideal to redo it once again .. as many have followed the same steps & worked fine for them.
DeleteYou must be missing something trivial
I get the following error when I run the ANT build:
ReplyDelete[junitreport] Loading stylesheet jar:file:/C:/Eclipse/eclipse/plugins/org.apache.ant_1.8.2.v20120109-1030/lib/ant-junit.jar!/org/apache/tools/ant/taskdefs/optional/junit/xsl/junit-frames.xsl
[junitreport] : Error! The first argument to the non-static Java function 'replace' is not a valid object reference.
[junitreport] : Error! Cannot convert data-type 'void' to 'reference'.
[junitreport] : Fatal Error! Could not compile stylesheet
[junitreport] Failed to process C:\Documents and Settings\Administrator\workspace\Home\junit\TESTS-TestSuites.xml
There are some references which you are missing .
DeleteCan you post your build.xml file & also ensure you have added all necessary jars please
The Eclipse Bug is clearly documented Bug 384757. The analysis suggests that Oracle introduced the bug.
Deletehttps://bugs.eclipse.org/bugs/show_bug.cgi?id=384757
If you are using Eclipse/JUnit report with JDK 1.7, please use JDK 1.6. There is a bug in JDK 1.7 with Eclipse/JUnit report similar to what you describe.
This comment has been removed by the author.
ReplyDeleteHi,
ReplyDeleteWorked absolutely fine with out changing any of the steps in Eclipse indigo,java6,junit4.
See this also : http://earlwillis.wordpress.com/2012/01/31/getting-started-with-junit-reports/
Hello, Anirban above quoted this page in my post: http://uaihebert.com/?p=63
ReplyDeleteNice material. [=
hi ,
ReplyDeleteI am getting xml files instead of html !!...help me ....
I followed the above mentioned steps