2 Replies Latest reply on Nov 19, 2011 7:47 AM by Hanspeter Gisler

    Forget to shrinkwrap a required class but arquillian pretends 100% test success?

    Hanspeter Gisler Newbie

      Hi,

       

      My environment: maven 3, glassfish 3.1, netbeans 7, testng, arquillian, arquillian-resolver

       

      A strange behaviour of arquillian is observed if declaring a test class instance variable of a type, that is not shrinkwrapped to the test package. The situation is as follows:

       

      The following code works as expected, i.e. aTest() fails:

      {code}package org.test.demo;

       

      import org.jboss.arquillian.container.test.api.Deployment;

      import org.jboss.arquillian.testng.Arquillian;

      import org.jboss.shrinkwrap.api.ShrinkWrap;

      import org.jboss.shrinkwrap.api.spec.JavaArchive;

      import org.testng.annotations.Test;

      import static org.testng.AssertJUnit.*;

       

      public class DebugTest extends Arquillian {

       

          @Deployment

          public static JavaArchive createTestArchive() {

              return ShrinkWrap.create(JavaArchive.class, "test.jar").addClass(ProhibitedCharacterFoundException.class);

          }

       

          //Client client;

          @Test

          public void aTest() throws ProhibitedCharacterFoundException {

              assertTrue(false);

          }

      }{code}

       

      However, if I add a declaration with a class which I do forget to add via shrinkwrap, like so:

      {code}...

      public class DebugTest extends Arquillian {

       

      Client client;

       

      @Deployment

          public static JavaArchive createTestArchive() {

              return ShrinkWrap.create(JavaArchive.class, "test.jar").addClass(ProhibitedCharacterFoundException.class);

          }

      ...{code}

      then aTest() get's not executed, but no error whatsoever is shown. Instead, Netbeans shows 100% test success!

      (Note: the test really doesn't get executed, no breakpoints which would be set inside aTest() would be hit: no code gets executed).

       

      Only after also including the two Classes: Clinet.class and SenseObject.class (Client is subclass of SenseObject) via shrinkwrap, aTest() works as expected, like so:

      {code}...

      public class DebugTest extends Arquillian {

       

      Client client;

       

      @Deployment

          public static JavaArchive createTestArchive() {

              return ShrinkWrap.create(JavaArchive.class, "test.jar").addClasses(Client.class, SenseObject.class,ProhibitedCharacterFoundException.class);

          }

      ...{code}

      What got me worked up quite a bit is the fact, that on first sight, the (non working test) seems to work perfectly and the test even seems to pass.

      I certainly would expect to get some error from arquillian, when declaring classes which have been forgotten to be shrinkwrapped.

       

      Or is something with my configuration amiss?

       

      here are the relevant parts of my pom:

       

      {code:xml}

          ...

       

          <properties>

              <org.jboss.shrinkwrap.resolver.version>1.1.0-alpha-1</org.jboss.shrinkwrap.resolver.version>

          </properties>

       

         <prerequisites>

              <maven>3.0.3</maven>

          </prerequisites>

       

          <profiles>

              <profile>

                  <id>glassfish-remote-3.1</id>

                  <dependencies>

                      <dependency>

                          <groupId>org.jboss.arquillian.container</groupId>

                          <artifactId>arquillian-glassfish-remote-3.1</artifactId>

                          <version>1.0.0.CR2</version>

                          <scope>test</scope>

                      </dependency>

                  </dependencies>

                  <build>

                      <testResources>

                          <testResource>

                              <directory>src/test/resources</directory>

                          </testResource>

                      </testResources>

                  </build>

              </profile>

          </profiles>

       

          <dependencies>

              <dependency>

                  <groupId>org.testng</groupId>

                  <artifactId>testng</artifactId>

                  <version>6.3</version>

                  <scope>test</scope>

              </dependency>

       

              <!-- attention!! separate guice is needed by testng version >= 6.0 -->

              <dependency>

                  <groupId>com.google.inject</groupId>

                  <artifactId>guice</artifactId>

                  <version>3.0</version>

                  <scope>test</scope>

              </dependency>

       

              <dependency>

                  <groupId>org.jboss.arquillian.testng</groupId>

                  <artifactId>arquillian-testng-container</artifactId>

                  <version>1.0.0.CR5</version>

                  <scope>test</scope>

              </dependency>

       

              <!-- shrinkwrap resolver -->

              <dependency>

                  <groupId>org.jboss.shrinkwrap.resolver</groupId>

                  <artifactId>shrinkwrap-resolver-api</artifactId>

                  <version>${org.jboss.shrinkwrap.resolver.version}</version>

                  <scope>test</scope>

              </dependency>

              <dependency>

                  <groupId>org.jboss.shrinkwrap.resolver</groupId>

                  <artifactId>shrinkwrap-resolver-api-maven</artifactId>

                  <version>${org.jboss.shrinkwrap.resolver.version}</version>

                  <scope>test</scope>

              </dependency>

              <dependency>

                  <groupId>org.jboss.shrinkwrap.resolver</groupId>

                  <artifactId>shrinkwrap-resolver-impl-maven</artifactId>

                  <version>${org.jboss.shrinkwrap.resolver.version}</version>

                  <scope>test</scope>

              </dependency>

          </dependencies>

       

          ...{code}