It's all about the answers!

Ask a question

Junit Test with Jazz, how?


Stefan Hufnagl (29411920) | asked Aug 23 '07, 4:02 a.m.
Hi @all,

Junit Test:
* I saw some hints and screendumps how to include Junit Test in Jazz. Jazz Wiki showed some examples inside CodeCoverage
* But the "ToDo" it is not really clear for me.


Questions:
* Where is the starting point?
* Should I include the Junit Tests in the build (build properties)?
* Is it the "run.coverage", "run.test" property?
* How to I include the results?

Thanks in advance

Stefan

11 answers



permanent link
Ryan Manwiller (1.3k1) | answered Aug 23 '07, 3:01 p.m.
JAZZ DEVELOPER
Hi Stefan,

It is not clear to me what you want when you say "JUnit test in Jazz".

If you are talking about seeing JUnit results within build results for your
automated builds, I can point you to the following:

Getting started with Jazz Builds
https://jazz.net/learn/LearnItem.jsp?href=content/docs/build-setup/index.html

There is also a concrete example of a build script that publishes compile
and JUnit results to Jazz. You will find it where you installed the
TeamConcert client at this path:
/jazz/buildsystem/buildtoolkit/examples/compile-and-test

Hope this helps,
Ryan

permanent link
Stefan Hufnagl (29411920) | answered Aug 28 '07, 3:58 p.m.
Hi Ryan,

thanks for your hint...

Result:
* Junit and other things like "download" work in the buildresults
* Codecoverage not (a log4j problem?)

Question:
* It seems that the build.xml is important ==> a normal build.xml must be manually changed?

Regards,

Stefan

permanent link
Ryan Manwiller (1.3k1) | answered Aug 28 '07, 8:03 p.m.
JAZZ DEVELOPER
Hi Stefan,

Getting code coverage results in your build results takes a little extra
work. We understand there is a need for a code coverage example. There is a
work item for it. I would suggest subscribing to work item 26371 to follow
along.

https://jazz.net/jazz/web/projects/Jazz%20Project#perspective=Work%20Items&action=viewWorkItem&id=26371

permanent link
Stefan Hufnagl (29411920) | answered Aug 29 '07, 10:31 a.m.
Hi Ryan,

is there a way to help you ? (or with the work item?)

Regards,

Stefan

permanent link
Ryan Manwiller (1.3k1) | answered Aug 29 '07, 11:18 a.m.
JAZZ DEVELOPER
Hi Stefan,

My advice is to ask the owner of the work item, in a work item comment.

permanent link
John Reysa (8876) | answered Jul 22 '09, 7:31 p.m.
I am looking at adding automated testing to our RTC automated build.

We were able to run the following example in https://jazz.net/wiki/bin/view/Main/AntBuildCompileAndTest
- This is a simple example using the Ant option
- Is there anything that shows an eclipse product being tested with some junit tests located in separate plug-in projects?

Our current build is using the SCM Command Line Interface option
We did put in a <junit> section in one of our current steps and was able to run a test, but we have a couple problems
- How do we include the product classpath that was used for the build since the build used the product definition I assume to create the classpath
- Can we specify our junit eclipse launcher so we can include some environment options and vm arguments that influence the testing

permanent link
Nick Edgar (6.5k711) | answered Jul 29 '09, 3:33 p.m.
JAZZ DEVELOPER
If you want to run JUnit tests within the context of a running Eclipse instance, you do so by running an eclipse application that runs the tests you want. This lets Eclipse/OSGi bootstrap everything as it normally does, then runs the tests within that context.

The test runner applications are in the org.eclipse.test plug-in, which you'll need to include in the eclipse target that you're testing (or copy it in as part of the build script).
The org.eclipse.test plug-in is found in the "JUnit Plugin Tests and Automated Testing Framwork" section of the Eclipse downloads page, named eclipse-test-framework-<version>.zip.

Its plugin.xml defines 2 application extensions: org.eclipse.test.coretestapplication and org.eclipse.test.uitestapplication. The first is headless (tests run directly with no UI), the latter runs with the workbench UI (tests run in the UI thread after the workbench is up and running).

The library.xml file in that zip provides some Ant tasks to invoke these applications.

The testframework.html in that zip provides some doc. You can read it directly here:
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.test/testframework.html?view=co

Hope this helps,
Nick

permanent link
guey-ing chang (11) | answered Aug 12 '10, 6:50 p.m.
I have a plug-in (e.g. com.ibm.hello.tests) which contains all JUnit testcases for another plug-in(e.g. com.ibm.hello). How can I automate the build process so after com.ibm.hello.tests is compiled, it automatically run the testcases and show reports. Both plug-in here are "native" components. What I need to add in build.xml to enable this automation? My env. is CCB/RTC.

Thanks.

permanent link
Nick Edgar (6.5k711) | answered Aug 16 '10, 4:53 p.m.
JAZZ DEVELOPER
The example here shows how to use PDE Build to build plugins, run tests against the built plugins using the Eclipse test framework, and publish results using the Build Toolkit Ant tasks (like jdtCompileLogPublisher and junitLogPublisher).

https://jazz.net/wiki/bin/view/Main/BuildFAQ#PdeBuild

Some key excerpts are:

In buildfiles/buildAll.xml:

<!-- Execute top level test script -->
<ant antfile="${team.scm.fetchDestination}/buildfiles/test.xml" />


In buildfiles/test.xml:

<macrodef name="runTests">
...
<ant antfile="${eclipse-home}/plugins/@{testPlugin}_${@{testPlugin}}/test.xml" dir="${eclipse-home}" />
...
</macrodef>
...
<target name="teamcore">
<runTests testPlugin="org.eclipse.team.tests.core" />
</target>


In org.eclipse.team.tests.core/test.xml:

<property name="library-file" value="${eclipse-home}/plugins/org.eclipse.test/library.xml"/>
...
<ant target="ui-test" antfile="${library-file}" dir="${eclipse-home}">
<property name="data-dir" value="${location}"/>
<property name="plugin-name" value="org.eclipse.team.tests.core"/>
<property name="classname" value="org.eclipse.team.tests.core.AllTeamUITests"/>
</ant>
...


In buildfiles/library.xml (copied and modified from the Eclipse test framework):

<property name="formatter" value="org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter"/>
...
<java fork="true" dir="." timeout="${timeout}" jvm="${jvm}" logError="true"
classname="org.eclipse.core.launcher.Main" output="${junit-report-output}/${classname}.txt">
<classpath>
<fileset dir="${eclipse-home}/plugins">
<include name="org.eclipse.equinox.launcher_*.jar"/>
</fileset>
</classpath>
<arg line="-application ${application}"/>
<arg line="-data ${data-dir}"/>
<arg line="formatter=${formatter},${test-output}"/>
<arg line="-testPluginName ${plugin-name}"/>
<arg line="-className ${classname}"/>
<arg line="-os ${os}"/>
<arg line="-ws ${ws}"/>
<arg line="-arch ${arch}"/>
<arg line="-consolelog"/>
<jvmarg line="${vmargs} ${extraVMargs}"/>
<sysproperty key="PLUGIN_PATH" value="${plugin-path}"/>
</java>

<!--junitLogPublisher is an RTC Build system custom Ant task used to publish JUnit results to
an RTC build result-->
<junitLogPublisher
filePath="${test-output}"
buildResultUUID="${buildResultUUID}"
repositoryAddress="${repositoryAddress}"
userId="${userId}"
password="${password}"
/>


Note the use of the XMLJUnitResultFormatter (from Ant) to output the JUnit results in an XML file that can be parsed by RTC's junitLogPublisher task.

permanent link
guey-ing chang (11) | answered Aug 19 '10, 3:08 p.m.
thanks for the reply. I have been playing with similar stuff found from google search, but can not get it work. I try to add one more block in our build.xml which is the component build script to do CCB build(ours test component is a native component so we create our own build.xml to do the CCB build). In build.xml, it goes thru. clean, init, compile, run_junit_plugin_tests, dist(to jar plug-in)and build(zip the jar). The following is run_junit_plugin_tests which try to combine test.xml and library.xml together.

My question are these:
1. is it(combine everything all together)workable?
2. where should be "dir" when running this target? currently, I put ${jazzWorkspacePath}\component, is this ok?
or it should be C\timestamp\component?
3. what's classpath and workspace should be when running this run_junit_plugin_tests?

Currently by running the build.xml, it fails with
Error Processing: org.eclipse.equinox.internal.p2.extensionlocation.SiteListener@478f478f: java.lang.NumberFormatException: For input string: "0_v20100816_1317"
java.lang.Exception: Could not find plugin "com.ibm.nex.console.web.server.tests"


<target>
<classpathref> -->
<property>
<java>
<classpath>
<fileset>
<include>
<include>
</fileset>

</classpath>
<arg>
</java>
</target>

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.