2 Replies Latest reply on Jan 7, 2010 6:50 PM by tengen

    Difference between the "Testcycle" of TestNG-Plugin and Maven

      Hi all,


      I have the following problem:


      I have written a test with TestNG in a maven project to test my database. The test runs in the JBoss Embedded Server.
      The structure of the project:


      src
      -main
      -test
      ------bootstrap
      ----------------lib
      ----------------resources


      And so on.


      In the lib-directory are the jars (jboss-embedded, etc.), which are need for the test.


      Now the problem:
      If I want to run the test with the TestNG-Plugin I do the following settings:
      Classpath-Bootstrap Settings: Adding the jars from the lib-directory.
      Adding the bootstrap-directory.
      VMArgs: -Dsun.lang.ClassLoader.allowArraySyntax true


      The test is running perfectly.


      But now I want to configurate the test with Maven. In my pom.xml I do the following settings:<dependency>
          <groupId>org.testng</groupId>
          <artifactId>testng</artifactId>
          <version>5.8</version>
          <scope>test</scope>
          <classifier>jdk15</classifier>
      </dependency>

      <project>
        [...]
        <build>
          <plugins>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-surefire-plugin</artifactId>
              <configuration>
                <additionalClasspathElements>
                      <additionalClasspathElement>src/test/bootstrap/lib</additionalClasspathElement>
                      <additionalClasspathElement>src/test/bootstrap/lib</additionalClasspathElement>
                </additionalClasspathElements>
              </configuration>
            </plugin>
          </plugins>
        </build>
        [...]
      </project>


      Additionally I have added the bootstrap-folder in the pom.xml
      Based on the debug outputs the jars are loading in the classpath. But the following error occurs:
      Unable to bootstrap.
      If I declare exactly the same jars from my local repository like <dependency>...</dependency> the same error occurs.


      Therefore my question: Is there a difference between the testcycle of the TestNG-Plugin and Maven?


      Any help is appreciated.


      Regards

        • 1. Re: Difference between the "Testcycle" of TestNG-Plugin and Maven

          Sorry that didn't format correctly. So here the correct format:
          I have the following problem:


          I have written a test with TestNG in a maven project to test my database. The test runs in the JBoss Embedded Server. The structure of the project:


          src 
          -main 
          -test 
          ------bootstrap 
          ----------------lib
          ----------------resources



          And so on.


          In the lib-directory are the jars, which are need for the test.



          Now the problem: If I want to run the test with the TestNG-Plugin I do the following settings: Classpath-Bootstrap Settings: Adding the jars from the lib-directory. Adding the bootstrap-directory. VMArgs:

           -Dsun.lang.ClassLoader.allowArraySyntax=true 



          The test is running perfectly.


          But now I want to configurate the test with Maven. In my pom.xml I do the following settings:


          <dependency> 
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId> 
            <version>5.8</version> 
            <scope>test</scope> 
            <classifier>jdk15</classifier> 
            </dependency>



          <project> 
          [...]
           <build>
             <plugins>
                <plugin>
                  <groupId>org.apache.maven.plugins</groupId>
                   <artifactId>maven-surefire-plugin</artifactId>
                   <configuration>
                      <additionalClasspathElements>
                          <additionalClasspathElement>src/test/bootstrap/lib</additionalClasspathElement> 
                      <additionalClasspathElement>src/test/bootstrap/lib</additionalClasspathElement>
                       </additionalClasspathElements>
                   </configuration>
                </plugin>
             </plugins>
            </build>
              [...] 
          </project>




          Additionally I have added the bootstrap-folder in the pom.xml Based on the debug outputs the jars are loading in the classpath. But the following error occurs: Unable to bootstrap. If I declare exactly the same jars from my local repository like

          <dependency>...</dependency>

          the same error occurs.


          Therefore my question: Is there a difference between the testcycle of the TestNG-Plugin and Maven?


          Any help is appreciated.


          Regards

          • 2. Re: Difference between the "Testcycle" of TestNG-Plugin and Maven
            tengen

            Add:


            <argLine>-Dsun.lang.ClassLoader.allowArraySyntax=true</argLine>
            



            to your surefire plugin configuration element. For example:


             <build>
               <plugins>
                  <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                     <artifactId>maven-surefire-plugin</artifactId>
                     <configuration>
                        <argLine>-Dsun.lang.ClassLoader.allowArraySyntax=true</argLine>
                        <additionalClasspathElements>
                            <additionalClasspathElement>src/test/bootstrap/lib</additionalClasspathElement> 
                        <additionalClasspathElement>src/test/bootstrap/lib</additionalClasspathElement>
                         </additionalClasspathElements>
                     </configuration>
                  </plugin>
               </plugins>
              </build>