5 Replies Latest reply on Aug 5, 2008 4:38 PM by Pete Muir

    testNG and integration testing

    System Administrator Expert

      I am getting ready to create some integration tests for my existing Seam 2.0 app.


      how many of you Seam devs out there are using testNG for unit and integration testing?  which is more valuable to you, unit or integration tests?


      apparently you need to be familiar with the JSF lifecycle to write testNG integration tests...

        • 1. Re: testNG and integration testing
          System Administrator Expert

          I just tried running the included testNG integration tests in the booking example project from Seam 2.0.1.GA and got the following error.  I'm using JBDS 1.1.0.GA.


          [Parser] Running:
            C:\jboss-seam-2.0.1.GA\examples\booking\temp-testng-customsuite.xml
          
          FAILED CONFIGURATION: @BeforeClass init
          java.lang.RuntimeException: Could not create Component: authenticator
               at org.jboss.seam.init.Initialization.addComponent(Initialization.java:976)
               at org.jboss.seam.init.Initialization.installComponents(Initialization.java:898)
               at org.jboss.seam.init.Initialization.init(Initialization.java:576)
               at org.jboss.seam.mock.BaseSeamTest.startSeam(BaseSeamTest.java:939)
               at org.jboss.seam.mock.BaseSeamTest.init(BaseSeamTest.java:923)
               at org.jboss.seam.mock.SeamTest.init(SeamTest.java:42)
          Caused by: java.lang.IllegalArgumentException: You must specify org.jboss.seam.core.init.jndiPattern or use @JndiName: authenticator
               at org.jboss.seam.Component.getJndiName(Component.java:438)
               at org.jboss.seam.Component.<init>(Component.java:243)
               at org.jboss.seam.Component.<init>(Component.java:217)
               at org.jboss.seam.init.Initialization.addComponent(Initialization.java:961)
               ... 27 more
          ... Removed 22 stack frames
          SKIPPED CONFIGURATION: @BeforeMethod begin
          SKIPPED CONFIGURATION: @AfterMethod end
          SKIPPED CONFIGURATION: @AfterClass cleanup
          SKIPPED: testChangePassword
          
          ===============================================
              org.jboss.seam.example.booking.test.ChangePasswordTest
              Tests run: 1, Failures: 0, Skips: 1
              Configuration Failures: 1, Skips: 3
          ===============================================
          
          
          ===============================================
          booking-2.0.1.GA
          Total tests run: 1, Failures: 0, Skips: 1
          Configuration Failures: 1, Skips: 3
          ===============================================



          same error for all three classes in this package: org.jboss.seam.example.booking.test.


          There are no errors/problems in Eclipse IDE.  What's the problem here?

          • 2. Re: testNG and integration testing
            System Administrator Expert

            Now just read and followed section 33.3.1. Configuration of the Seam 2.0.1.GA ref doc.


            Noticed that there is no lib/test/jboss-embedded-api.jar in my distro of Seam 2.0.1.


            Is that a typo?


            I found it here: \jboss-seam-2.0.1.GA\lib


            Also, there was no mention of adding testNG.jar to the build path in Eclipse.


            the .classpath file contents is as follows for the booking project:


            <?xml version="1.0" encoding="UTF-8"?>
            <classpath>
                 <classpathentry kind="src" path="src"/>
                 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
                 <classpathentry kind="lib" path="C:/jboss-seam-2.0.1.GA/lib/test/thirdparty-all.jar"/>
                 <classpathentry kind="lib" path="C:/jboss-seam-2.0.1.GA/lib/test/hibernate-all.jar"/>
                 <classpathentry kind="lib" path="C:/jboss-seam-2.0.1.GA/lib/test/jboss-embedded-all.jar"/>
                 <classpathentry kind="lib" path="C:/jboss-seam-2.0.1.GA/lib/jboss-embedded-api.jar"/>
                 <classpathentry kind="lib" path="C:/jboss-seam-2.0.1.GA/lib/jboss-seam.jar"/>
                 <classpathentry kind="lib" path="C:/jboss-seam-2.0.1.GA/lib/jboss-el.jar"/>
                 <classpathentry kind="lib" path="C:/jboss-seam-2.0.1.GA/lib/jsf-api.jar"/>
                 <classpathentry kind="lib" path="C:/jboss-seam-2.0.1.GA/lib/activation.jar"/>
                 <classpathentry kind="lib" path="bootstrap"/>
                 <classpathentry kind="lib" path="C:/jboss-seam-2.0.1.GA/lib/testng.jar"/>
                 <classpathentry kind="output" path="bin"/>
            </classpath>



            now I'm seeing the following when I run a testNG test case:


            [Parser] Running:
              C:\jboss-seam-2.0.1.GA\examples\booking\temp-testng-customsuite.xml
            
            
            ===============================================
            booking-2.0.1.GA
            Total tests run: 0, Failures: 0, Skips: 0
            ===============================================
            
            java.lang.NoClassDefFoundError: [Ljavax/el/ELResolver;
                 at java.lang.Class.getDeclaredMethods0(Native Method)
                 at java.lang.Class.privateGetDeclaredMethods(Class.java:2395)
                 at java.lang.Class.getDeclaredMethods(Class.java:1763)
                 at org.testng.internal.annotations.AnnotationHelper.findMethodsWithAnnotation(AnnotationHelper.java:201)
                 at org.testng.internal.TestNGMethodFinder.getTestMethods(TestNGMethodFinder.java:48)
                 at org.testng.TestClass.initMethods(TestClass.java:110)
                 at org.testng.TestClass.init(TestClass.java:74)
                 at org.testng.TestClass.<init>(TestClass.java:43)
                 at org.testng.TestRunner.initMethods(TestRunner.java:288)
                 at org.testng.TestRunner.init(TestRunner.java:216)
                 at org.testng.TestRunner.init(TestRunner.java:178)
                 at org.testng.TestRunner.<init>(TestRunner.java:139)
                 at org.testng.remote.RemoteTestNG$1.newTestRunner(RemoteTestNG.java:102)
                 at org.testng.remote.RemoteTestNG$DelegatingTestRunnerFactory.newTestRunner(RemoteTestNG.java:154)
                 at org.testng.SuiteRunner$ProxyTestRunnerFactory.newTestRunner(SuiteRunner.java:494)
                 at org.testng.SuiteRunner.privateRun(SuiteRunner.java:235)
                 at org.testng.SuiteRunner.run(SuiteRunner.java:191)
                 at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:808)
                 at org.testng.TestNG.runSuitesLocally(TestNG.java:776)
                 at org.testng.TestNG.run(TestNG.java:701)
                 at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:73)
                 at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:124)

            • 3. Re: testNG and integration testing
              Daniel Hinojosa Master

              Are you running all this goodness out of seam-gen or your own build and classpath?

              • 4. Re: testNG and integration testing
                System Administrator Expert

                I don't really understand your question.  I created a new java project pointing to the hotel booking folder in the examples folder.


                If I create a new Seam project in JBDS, then create a new Seam action, the test runs fine.  The build path was wrong...


                But you'd think the distro examples would work find out of the box for integration testing (unless something is wrong with my workspace??)

                • 5. Re: testNG and integration testing
                  Pete Muir Master

                  Noticed that there is no lib/test/jboss-embedded-api.jar in my distro of Seam 2.0.1.

                  Is that a typo?

                  Yes.


                  Please use the current stable release of Seam.


                  Also, there was no mention of adding testNG.jar to the build path in Eclipse.


                  Ok, I stated the obivous in the docs now. I also mentioned that you need el-api.jar.