JBossWiki : JSFUnitWithAnt
Wiki Home: JSFUnitWithAnt [EN]
[Permalink]
[Recent Changes]
[History]
[RSS Feed][RDF Feed][Atom Feed][Print]

Your trail: JSFUnitWithAnt

Integrating JSFUnit with Ant requires a few steps.

  • Build your application into a war structure. (exploded directory or .war file)
    • For now we will not cover this step as it is project dependant.
  • Run the jsfunitwar task over the war created in step 1
    • Here is an example of how to do this
      <target name="create.jsfunit.exploded.dir" depends="compile.test">
      	<path id="jsfunit.classpath">
      	    <fileset dir="${lib.dir}/jsf-unit">
      		<include name="**/*.jar"/>
      	    </fileset>
      	    <fileset dir="${lib.dir}/junit">
      		<include name="**/*.jar"/>
      	    </fileset>
      	    <fileset dir="${lib.dir}/aspectj">
      		<include name="**/*.jar"/>
      	    </fileset>
      	</path>
      
      	<taskdef
      	    name="jsfunitwar"
      	    classname="org.jboss.jsfunit.ant.JSFUnitWarTask"
      	    classpathref="jsfunit.classpath"/>
      
      	<jsfunitwar srcfile="${exploded.dir}"
      		    destfile="${exploded-jsfunit.dir}"
                          autoaddjars="true">
      		
      		<!-- This is where you have compiled your jsfunit tests -->
      		<classes dir="${classes.test}"
      		     includes="**/jsfunit/**/*.class">
      		</classes>
      		
      		<TestRunner/>
      	</jsfunitwar>
      </target>
      
  • Deploy the newly created war file/folder to your server
    • Once again this is project specific and will not be covered by this wiki topic.
  • Run the jsf unit tests
    • Here is an example ant target for running the tests. Obviously some things here you will need to change or remove. But this is the general idea.
      <target name="run.full.suite">
          <mkdir dir="${junit.xml.dir}" />
      
          <junit
              showoutput="yes"
              fork="yes"
              printsummary="yes"
              haltonfailure="yes"
              haltonerror="yes">
      
              <classpath>
                  <fileset dir="${lib.dir}">
                      <include name="**/*.jar" />
                  </fileset>
                  <pathelement location="${classes.test}" />
                  <pathelement location="${classes.prod}" />
              </classpath>
      
              <jvmarg value="-Dcactus.contextURL=http://${tomcat.hostname}:${tomcat.port}/${tomcat.gekko.webapp}" />
      
              <formatter type="xml" usefile="yes" />
      
              <test name="gekko.web.jsfunit.GekkoWebJSFFullSuite"
                  todir="${junit.xml.dir}"
                  outfile="${junit.report.file}" />
          </junit>
      
      
          <junitreport
              todir="${junit.xml.dir}"
              tofile="${junit.report.file}">
              
              <fileset dir="${junit.xml.dir}">
                  <include name="*.xml" />
              </fileset>
              
              <report
                  todir="${junit.xml.dir}"
                  styledir="${lib.dir}/jsf-unit"
                  format="noframes" />
          </junitreport>
          
      </target>
      

This documentation for itegrating JSFUnit with Ant is a work in progress.

You may consider the following links useful.

JBoss.com - Forums - JSFUnitwar Ant Task
JBoss.com - Forums - JSFUnit/Ant/Cargo

Also, in the JSFUnit example code, there is a Maven pom that "JSFUnifies" a WAR and runs JSFUnit tests against that WAR. You can browse that example and its POM here: http://fisheye.jboss.org/browse/JSFUnit/trunk/jboss-jsfunit-examples/jboss-jsfunit-examples-hellojsf/jboss-jsfunit-examples-hellojsf-ant

Note that right now the Ant task is called "<jsfunitwar>", but we will be changing the name to "<jsfunify>".

Referenced by:
JSFUnitDocumentation
RunningJSFUnit


Other languages:

Log in to make links between pages

The page last changed on Sun Aug 24 15:18:56 EDT 2008 by stan.silvert@jboss.com