4 Replies Latest reply on Oct 21, 2009 3:15 AM by Pucky Loucks

    Maven and JSFUnit how to fail build

    Pucky Loucks Newbie

      Hi Stan,

      I've got my maven build working and running my JSFUnit durning the integration-test phase of the build. I've got Bamboo checking out and building and maven is downloading jboss, starting jboss and running the JSFUnit tests...... which is great except I'm not sure how to tell maven to fail if a JSFUnit test fails. Any idea?

      Once i get this all working, I'm going to create a demo project and share with all so that this is clear how to setup, as I've had issues along the way and which I could have seen an example of how to do this.

      Thanks,
      Pucky

        • 1. Re: Maven and JSFUnit how to fail build
          Stan Silvert Master

          By default, a failed test will make the Maven build fail. So I'm wondering about your configuration. I don't know anything about Bamboo, but if you are using the Surefire plugin to run your tests from Maven then this should work.

          Stan

          • 2. Re: Maven and JSFUnit how to fail build
            Pucky Loucks Newbie

            Thanks Stan,

            It was my configuration I was putting the url to the /ServletTestRunner?suite=etc... in the deployer ping and not doing it correctly with surefire.

            So now I have surefire all setup and the build is going along but it's saying no tests. So I guess I'm not quite there yet.

            My application is deployed as an Ear and I've got the ServletTestRunner working via the browser. here's my configuration.

            =============snippet of EAR pom.xml =================

            <plugin>
             <groupId>org.codehaus.cargo</groupId>
             <artifactId>cargo-maven2-plugin</artifactId>
             <version>1.0.1-alpha-1</version>
             <configuration>
             <wait>false</wait>
             <container>
             <containerId>jboss4x</containerId>
             <output>${project.build.directory}/jboss4x.log</output>
             <log>${project.build.directory}/cargo.log</log>
             <zipUrlInstaller>
             <url>
             http://somehostname.s3.amazonaws.com/jboss-4.3.0.GA.zip
             </url>
             <installDir>${basedir}</installDir>
             </zipUrlInstaller>
             <systemProperties>
             <jboss.server.log.threshold>INFO</jboss.server.log.threshold>
             </systemProperties>
             </container>
             <configuration>
             <type>existing</type>
             <home>
             ${basedir}/jboss-4.3.0.GA/server/default
             </home>
             <properties>
             <jboss.server.log.threshold>INFO</jboss.server.log.threshold>
             <cargo.jboss.configuration>default</cargo.jboss.configuration>
             <cargo.jvmargs>-XX:PermSize=512m -XX:MaxPermSize=1024 -XX:+UseConcMarkSweepGC
             -XX:+CMSPermGenSweepingEnabled -XX:+CMSClassUnloadingEnabled
             </cargo.jvmargs>
             <cargo.runtime.args>-u admin -p admin -b 127.0.0.1</cargo.runtime.args>
             <cargo.rmi.port>1299</cargo.rmi.port>
             <cargo.servlet.port>8181</cargo.servlet.port>
             </properties>
             <deployables>
             <deployable>
             <location>ear/target/myapp-ear.ear</location>
             <type>ear</type>
             </deployable>
             </deployables>
             </configuration>
             </configuration>
             <executions>
             <execution>
             <id>start-container</id>
             <phase>pre-integration-test</phase>
             <goals>
             <goal>start</goal>
             </goals>
             </execution>
             <execution>
             <id>stop-container</id>
             <phase>post-integration-test</phase>
             <goals>
             <goal>stop</goal>
             </goals>
             </execution>
             </executions>
             </plugin>
             <plugin>
             <groupId>org.apache.maven.plugins</groupId>
             <artifactId>maven-surefire-plugin</artifactId>
             <!-- We only want test to run during integration-test phase -->
             <configuration>
             <skip>true</skip>
             </configuration>
             <executions>
             <execution>
             <id>surefire-it</id>
             <phase>integration-test</phase>
             <goals>
             <goal>test</goal>
             </goals>
             <configuration>
             <skip>false</skip>
             <systemProperties>
             <property>
             <name>cactus.contextURL</name>
             <value>http://localhost:8181/</value>
             </property>
             </systemProperties>
             </configuration>
             </execution>
             </executions>
             </plugin>


            ==============================================

            so I guess my question is the following. When surefire runs does it run the test files from within the build process and connect to the server via cactus? or does surefire tell cactus to hit the URL that is used via the browser.

            My Tests are within the web project src/main/java so that they get deployed with the running code. (again work great in the browser) So I think that I'm missing an obvious step. It would seem that if JSFUnit works like all other unit testing with surefire then those tests would be within src/test/java and then cactus would be the part that is connecting surefire to the container to run the tests is this what I'm missing?

            Thanks so much Stan, I kinda excited about all this.

            by the way bamboo is just like hudson and cruisecontrol. just another CI tool. (i'm sure i'll get slapped for that simplification)



            • 3. Re: Maven and JSFUnit how to fail build
              Stan Silvert Master

              I think you've got the right idea. To Maven, it looks like the tests are running locally. But Cactus redirects the tests to your server and runs them there.

              I assume you've already been looking at this:
              http://www.jboss.org/community/wiki/JSFUnitWithMaven

              I also suggest that you take a look at this to learn a little more about how Cactus works:
              http://jakarta.apache.org/cactus/how_it_works.html

              For JSFUnit, we use the Servlet Redirector Proxy.

              This is also helpful:
              http://jakarta.apache.org/cactus/integration/manual/howto_config.html

              Stan

              • 4. Re: Maven and JSFUnit how to fail build
                Pucky Loucks Newbie

                Bingo, I got it all working WOOT!!! Thanks so much Stan this is awesome.


                I've got another question, but I'll open a new thread for it.

                Cheers,
                Pucky