• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

generate junit reports

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello everybody,
I am new in junit and I would like to generate a very simple report of how many tests succeeded, how failed and the name of the tests that succeeded and failed.
It's a part of a plug in that we create and I want it to happen when the user run the tests (I don't want to run them myself).
Also it mustn't be a report - If I have another way to collect the information it would be fine.

Thank you very much
hadas
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hadas,
Welcome to JavaRanch!

If you can use Ant to run JUnit, the JUnit report task generates a nice HTML report. If not, you could write your own JUnit test runner and hook into JUnit directly to get the data.
 
hadas yaari
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jeanne, thanks for the quick response.
I don't want to build a runner because I want the user not to change his work ways.
I don't know the ANT - can I tell him to generate the report by programing (in the java code)?
I thought maybe I could add a listener that after every test will get somehow the results of the tests. Is it possible?
I'm looking for a very simple way to implement it.
This is a project for the university and we are creating a plug-in that his goal is to improve the programmer development environment when the compnay has several sites all around the world. So in addition to other information that we want to send to the next site in the end of workday, we want to send also a test report.

I would be happy if someone would lead me to the way to implement it.
Thank you very much
Hadas
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A plug-in - for what? That is, what would you plug it in to, and how?

See whether http://junit.sourceforge.net/javadoc/org/junit/runner/notification/RunListener.html helps you...
 
hadas yaari
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ilja,
Thanks - this was very helpfull and I think I will use it.
The problem is that I will have to run the test by myself and not in the custom way (right button on the test -> run/debug).
Is there another way?
Hadas
 
Jeanne Boyarsky
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by hadas yaari:
The problem is that I will have to run the test by myself and not in the custom way (right button on the test -> run/debug).
Is there another way?


You could write/modify an IDE plugin to hook into the default one. This is why Ilja asked how you were running it.
 
Ilja Preuss
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by hadas yaari:

The problem is that I will have to run the test by myself and not in the custom way (right button on the test -> run/debug).
Is there another way?



Sounds like you are using some kind of IDE? Which one?
 
hadas yaari
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ilja,
I am using Eclipse
Thanks, Hadas
 
Ilja Preuss
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, as Jeanne already hinted at, you could probably write an Eclipse plugin that does this.

Are you sure that running the tests from the IDE is the best idea? It sounds a bit like what you want to do might be better done using a continuous integration server, like Hudson or Cruise Control.
 
hadas yaari
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ilja,
Thats exactly what I want - I want to add to my plugin the possibility to trac the test results and create a report acording to it.
Now I can trac the result of the unit tests that I run manually (by org.junit.runner.notification.RunListener after creating a new JUnitCore)
Is there any API I can use in order to get the wanted intformation?
Thanks
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<target name="SoapUITest">
<mkdir dir="${junit.output.dir}"/>
<junit fork="yes" printsummary="withOutAndErr">
<formatter type="xml"/>
<test name="soapUITest" todir="${junit.output.dir}"/>
<classpath refid="automation.classpath"/>
</junit>
</target>

You can run from ANT the test you mentioned and a report is generated automatically by ANT and JUnit.
soapUITest represents the class you are running as a test,

Hope this helps
 
Don't play dumb with me! But you can try this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic