6 Replies Latest reply on Feb 3, 2011 8:49 AM by marx3

    Arquillian - testing Weld application

    marx3

      Hello

      I'm trying to make applications withs tests. There is hovewer big mess with tests.

      My application will use Weld, Hibernate and JBoss AS6, is written in Eclipse, so it's rather usual configuration and first choice for CDI environment.

      1) testng or junit? Which one to use?

      2) Embedded or remote container? and what's managed container?

      Support matrix

      http://community.jboss.org/wiki/ArquillianContainerInjectionSupportMatrix

      doesn't help in choosing at all.

      Which one should I use? Remote AS 6? Embedded Weld?

      4) Maven hell...

      - I have to choose between testng and junit - both will not work together (ok, I can understand that, but it should be written somewhere)

      - Weld archetype has errors and in no way helps with Arquillian (ok, Arquillian is Alpha...)

      - everyone on the net use different method to launch tests with Arquillian, they use profiles or not, thay choose different containers, and what is worst - everyone use different version of Jboss, Arquillian, junit/testng etc. I can't simply tell Maven - use the newest compatible. No - I have to write version exect number. Some uses snapshots - but suddenly they are absent. Some version even doesn't exists but are advised in Arquillian documentation...

      5) I see in Weld archive that some examples uses selenium framework - but there is no description how to use them anywhere. I know Selenium, i know that richfaces team use it for internal testing, and it would be nice to be able to use it together with Arquillian. It should be described anywhere.

      6) Eclipse has plugins for Maven and testng/junit. There is no clear description how to use them together with Arquillian (and profiles). Usually there is need:

      - to deploy locally (local jboss) - it works ok from command line and from Maven plugin (using run configuration)

      - to test locally (local jboss, maybe embedded container for tests?) - tests are also run automatically with deploying, but if I have different profile for testing - they doesn't pass...). I can do "mvn test" and "mvn test -P"profile" - but how to use it with testng/junit plugin?

      7) Usually Hudson/Continuum or sth like this tests nightly builds and produce snaphots/releases - I hope that it will be possible to confugure it with junit/testng, Arquillian and maybe Selenium...?

      8) I've attached very simple project created from Weld archetype. I was trying to configure Arquillian test but they doesn't work:

      - "mvn package":

       

      {code}

      -------------------------------------------------------------------------------

      Test set: dummy.HelloTestCase

      -------------------------------------------------------------------------------

      Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.007 sec <<< FAILURE!

      initializationError(dummy.HelloTestCase)  Time elapsed: 0.002 sec  <<< ERROR!

      java.lang.NullPointerException

      at org.jboss.arquillian.impl.DeployableTestBuilder.build(DeployableTestBuilder.java:88)

      at org.jboss.arquillian.impl.DeployableTestBuilder.build(DeployableTestBuilder.java:77)

      at org.jboss.arquillian.junit.Arquillian.<init>(Arquillian.java:85)

      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)

      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)

      at java.lang.reflect.Constructor.newInstance(Constructor.java:513)

      at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:31)

      at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:24)

      at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)

      at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)

      at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)

      at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)

      at org.apache.maven.surefire.junit4.JUnit4TestSet.<init>(JUnit4TestSet.java:45)

      at org.apache.maven.surefire.junit4.JUnit4DirectoryTestSuite.createTestSet(JUnit4DirectoryTestSuite.java:56)

      at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.locateTestSets(AbstractDirectoryTestSuite.java:96)

      at org.apache.maven.surefire.Surefire.createSuiteFromDefinition(Surefire.java:209)

      at org.apache.maven.surefire.Surefire.run(Surefire.java:156)

      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

      at java.lang.reflect.Method.invoke(Method.java:597)

      at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)

      at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)

      {/code}

       

      - "mvn test -Pweld-ee-embedded-1.1",  "mvn test -Pjbossas-remote-60":

      {code}

      -------------------------------------------------------------------------------

      Test set: dummy.HelloTestCase

      -------------------------------------------------------------------------------

      Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.009 sec <<< FAILURE!

      initializationError(dummy.HelloTestCase)  Time elapsed: 0.002 sec  <<< ERROR!

      java.lang.NoClassDefFoundError: org/jboss/arquillian/spi/ExtensionConfiguration

      at org.jboss.arquillian.impl.XmlConfigurationBuilder.build(XmlConfigurationBuilder.java:112)

      at org.jboss.arquillian.junit.Arquillian.<init>(Arquillian.java:84)

      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)

      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)

      at java.lang.reflect.Constructor.newInstance(Constructor.java:513)

      at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:31)

      at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:24)

      at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)

      at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)

      at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)

      at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)

      at org.apache.maven.surefire.junit4.JUnit4TestSet.<init>(JUnit4TestSet.java:45)

      at org.apache.maven.surefire.junit4.JUnit4DirectoryTestSuite.createTestSet(JUnit4DirectoryTestSuite.java:56)

      at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.locateTestSets(AbstractDirectoryTestSuite.java:96)

      at org.apache.maven.surefire.Surefire.createSuiteFromDefinition(Surefire.java:209)

      at org.apache.maven.surefire.Surefire.run(Surefire.java:156)

      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

      at java.lang.reflect.Method.invoke(Method.java:597)

      at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)

      at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)

      Caused by: java.lang.ClassNotFoundException: org.jboss.arquillian.spi.ExtensionConfiguration

      at java.net.URLClassLoader$1.run(URLClassLoader.java:202)

      at java.security.AccessController.doPrivileged(Native Method)

      at java.net.URLClassLoader.findClass(URLClassLoader.java:190)

      at java.lang.ClassLoader.loadClass(ClassLoader.java:307)

      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)

      at java.lang.ClassLoader.loadClass(ClassLoader.java:248)

      ... 23 more

      {/code}

       

      Can anybody help me create working, testable project?

        • 1. Arquillian - testing Weld application
          aslak

          Have you looked at the Arquillian Reference Guide ? http://docs.jboss.org/arquillian/reference/latest/en-US/html_single/

          • 2. Arquillian - testing Weld application
            marx3

            of course.

            For example testng 5.12.1 version from example din't work and I had to exchange with 5.10...

            6.0.0.20100721-M4 version of jboss-as-client doesn't work too, I had to change to 6.0.0.Final to satisfy dependencies...

             

            I was trying to fire temperature example, of course without success, errors are the same as I've attached in first post.

            • 3. Arquillian - testing Weld application
              aslak

              Use arquillian-junit:1.0.0.Alpha4

               

              Use arquillian-jbossas-remote-6:1.0.0.Alpha4 (not ...remote-60)

              See http://docs.jboss.org/arquillian/reference/latest/en-US/html_single/#container.jbossas-remote-6 the example of depedencies needed by JBoss AS 6 remote container.

               

              arquillian-weld-ee-embedded-1.1 does not support Weld 1.1 in Alpha4, use Weld 1.1.0.Beta1

              • 4. Re: Arquillian - testing Weld application
                marx3

                1) i've changed all arquillian component versions to 1.0.0.Alpha4: arquillian-junit, arquillian-jbossas-remote-6, arquillian-weld-ee-embedded-1.1

                2) i've added dependencies from documentation: jboss-as-client:6.0.0.20100721-M4 and changed jboss-as-client:6.0.0.20100721-M4 to 6.0.0.Final

                3) i've changed weld-core-bom version in weld profile to 1.1.0.Beta1

                 

                - mvn package

                 

                {code}

                -------------------------------------------------------------------------------

                Test set: dummy.HelloTestCase

                -------------------------------------------------------------------------------

                Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.009 sec <<< FAILURE!

                initializationError(dummy.HelloTestCase)  Time elapsed: 0.002 sec  <<< ERROR!

                java.lang.NullPointerException

                at org.jboss.arquillian.impl.DeployableTestBuilder.build(DeployableTestBuilder.java:88)

                at org.jboss.arquillian.impl.DeployableTestBuilder.build(DeployableTestBuilder.java:77)

                at org.jboss.arquillian.junit.Arquillian.<init>(Arquillian.java:85)

                at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

                at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)

                at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)

                at java.lang.reflect.Constructor.newInstance(Constructor.java:513)

                at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:31)

                at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:24)

                at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)

                at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)

                at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)

                at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)

                at org.apache.maven.surefire.junit4.JUnit4TestSet.<init>(JUnit4TestSet.java:45)

                at org.apache.maven.surefire.junit4.JUnit4DirectoryTestSuite.createTestSet(JUnit4DirectoryTestSuite.java:56)

                at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.locateTestSets(AbstractDirectoryTestSuite.java:96)

                at org.apache.maven.surefire.Surefire.createSuiteFromDefinition(Surefire.java:209)

                at org.apache.maven.surefire.Surefire.run(Surefire.java:156)

                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

                at java.lang.reflect.Method.invoke(Method.java:597)

                at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)

                at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)

                {/code}

                 

                How to tell maven to use another profile to test, and to use default profile to deploy?

                 

                - mvn test -Pjbossas-remote-6

                SUCCESS!!!

                 

                - mvn test -Pweld-ee-embedded-1.1

                 

                {code}

                -------------------------------------------------------------------------------

                Test set: dummy.HelloTestCase

                -------------------------------------------------------------------------------

                Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.297 sec <<< FAILURE!

                dummy.HelloTestCase  Time elapsed: 0.303 sec  <<< ERROR!

                java.lang.NoSuchMethodError: org.jboss.weld.bootstrap.api.Bootstrap.parse(Ljava/lang/Iterable;)Lorg/jboss/weld/bootstrap/spi/BeansXml;

                at org.jboss.arquillian.container.weld.ee.embedded_1_1.mock.TestContainer.<init>(TestContainer.java:215)

                at org.jboss.arquillian.container.weld.ee.embedded_1_1.WeldEEMockContainer.deploy(WeldEEMockContainer.java:76)

                at org.jboss.arquillian.impl.handler.ContainerDeployer.callback(ContainerDeployer.java:62)

                at org.jboss.arquillian.impl.handler.ContainerDeployer.callback(ContainerDeployer.java:50)

                at org.jboss.arquillian.impl.event.MapEventManager.fire(MapEventManager.java:63)

                at org.jboss.arquillian.impl.context.AbstractEventContext.fire(AbstractEventContext.java:115)

                at org.jboss.arquillian.impl.EventTestRunnerAdaptor.beforeClass(EventTestRunnerAdaptor.java:96)

                at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:162)

                at org.jboss.arquillian.junit.Arquillian$3$1.evaluate(Arquillian.java:186)

                at org.jboss.arquillian.junit.Arquillian$MultiStatementExecutor.execute(Arquillian.java:297)

                at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:182)

                at org.junit.runners.ParentRunner.run(ParentRunner.java:236)

                at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:127)

                at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)

                at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)

                at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)

                at org.apache.maven.surefire.Surefire.run(Surefire.java:177)

                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

                at java.lang.reflect.Method.invoke(Method.java:597)

                at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)

                at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)

                {/code}

                 

                • 5. Re: Arquillian - testing Weld application
                  aslak

                  Arquillian requires a container to run, so if you don't have a default profile, e.g. profile/activation/activateByDefault=true where you can run the tests, then you have to setup the surefire plugin to skip tests by default. then set skip = false in the profiles.

                   

                  Do you have the surefire report for the failing test with the Weld container? target/surefire/...

                  • 6. Re: Arquillian - testing Weld application
                    marx3

                    1) I have default profile in ~/.m2/settings which I use to deploy to. So the option is:

                    -add test dependencies to <build> section in pom.xml, and maven will launch tests first on remote container, and next it will package and eventually hard deploy to this same container? Or should I edit default profile in settings...?

                    -skip test in default profile and use it to hard deploy, and test with another profile, because it can't be done simultanously?

                     

                    2) i've succesfully launched copy of project with test-ng on jboss remote profile, hovewer it fails on weld embedded too. I've attached complete projects with junit and test-ng, it contains surefire report test too