2 Replies Latest reply on Mar 2, 2015 9:15 PM by J Buddha

    Problem creating test for a new addon I'm developing

    J Buddha Newbie

      I'm creating a forge addon and following the below folder structure of having seperate addon, impl, tests and api folders. I wrote my Facet implementation in Impl. I'm able to successfully execute the addon. However, I want to create some unit tests to test my addon. I haven't even come to stage of writing tests to my addon. I have followed http://forge.jboss.org/document/test-your-addonhttp://forge.jboss.org/document/test-your-addon and created a sample test. This is what is there in my test

       

      @RunWith(Arquillian.class)

      public class FirstTest {

         @Deployment
         @Dependencies({

         @AddonDependency(name = "org.codehaus.griffon.forge:griffon-forge-addon", version = "1.0.0-SNAPSHOT") })

         public static ForgeArchive getDeployment() {

             ForgeArchive archive = ShrinkWrap.create(ForgeArchive.class)

                                                                .addBeansXML()

                                                                .addAsAddonDependencies(AddonDependencyEntry.create("org.codehaus.griffon.forge:griffon-forge-addon", "1.0.0-SNAPSHOT") );
             return archive;
         }

       

         @Test
         public void testSomething() throws Exception {

              Assert.fail("Not implemented");
         }

      }

       

      When I'm trying to run this test I'm getting the following error.

       

      testSomething(org.codehaus.griffon.forge.FirstTest): Test runner could not locate test class [org.codehaus.griffon.forge.FirstTest] in any deployed Addon.

       

      Can anyone tell me what is the process to be followed when writing tests for our addons if we follow the structure addon, api, impl and tests? Do we have to install the addon to test it? Isn't there any way to test the addon without first installing? Is it possible to test a Facet directly without running through Forge?

       

      Also in log when I try to run  the test I see following Warning

      WARNING: Addon [_DEFAULT_,e165a928-b624-4d65-bbc5-e44b290bd744 +MISSING HC: 453307127] has [1] missing dependencies: [Missing: name=org.codehaus.griffon.forge:griffon-forge-addon, version=1.0.0-SNAPSHOT, exported=false, optional=false] and will be not be loaded until all required dependencies are available.

       

      Why does my addon, which is in the same project not available for my test? am I missing something? I would appreciate if someone can point me to a place where I can find out how to write tests. This greatly reduces my development time.

        • 1. Re: [forge-users] Problem creating test for a new addon I'm      developing
          George Gastaldi Master

          Your test is missing the container. Make sure to add @AddonDependency(name="org.jboss.forge.furnace.container:cdi") to your @Deployment method.

           

           

           

          Em 01/03/2015, às 13:51, forge-users@lists.jboss.org escreveu:

           

          I'm creating a forge addon and following the below folder structure of having seperate addon, impl, tests and api folders. I wrote my Facet implementation in Impl. I'm able to successfully execute the addon. However, I want to create some unit tests to test my addon. I haven't even come to stage of writing tests to my addon. I have followed http://forge.jboss.org/document/test-your-addonhttp://forge.jboss.org/document/test-your-addon and created a sample test. This is what is there in my test

          @RunWith(Arquillian.class)

          public class FirstTest {

          @Deployment

             @Dependencies({

          @AddonDependency(name = "org.codehaus.griffon.forge:griffon-forge-addon", version = "1.0.0-SNAPSHOT") })

          public static ForgeArchive getDeployment() {

          ForgeArchive archive = ShrinkWrap.create(ForgeArchive.class)

                                                                    .addBeansXML()

                                                                    .addAsAddonDependencies(AddonDependencyEntry.create("org.codehaus.griffon.forge:griffon-forge-addon", "1.0.0-SNAPSHOT") );

                 return archive;

             }

           

          @Test

             public void testSomething() throws Exception {

          Assert.fail("Not implemented");

             }

          }

           

          When I'm trying to run this test I'm getting the following error.

           

          h5. testSomething(org.codehaus.griffon.forge.FirstTest): Test runner could not locate test class in any deployed Addon.

           

          Can anyone tell me what is the process to be followed when writing tests for our addons if we follow the structure addon, api, impl and tests? Do we have to install the addon to test it? Isn't there any way to test the addon without first installing? Is it possible to test a Facet directly without running through Forge?

           

          Posted by forums

          Original post: https://developer.jboss.org/message/920242#920242

           

          _______________________________________________

          forge-users mailing list

          forge-users@lists.jboss.org

          https://lists.jboss.org/mailman/listinfo/forge-users

           

          _______________________________________________

          forge-users mailing list

          forge-users@lists.jboss.org

          https://lists.jboss.org/mailman/listinfo/forge-users

           

           

          • 2. Re: Re: [forge-users] Problem creating test for a new addon I'm      developing
            J Buddha Newbie

            Hi gastaldi,

             

            I kept it and it still doesn't seem to work. Following is the exception I got when I executed maven install command on my tests sub-project.

             

            testSomething (org.codehaus.griffon.forge.FirstTest)  Time elapsed: 0.058 sec  <<< ERROR!

            java.lang.IllegalStateException: Test runner could not locate test class [org.codehaus.griffon.forge.FirstTest] in any deployed Addon.

                at org.jboss.forge.arquillian.ForgeTestMethodExecutor.invoke(ForgeTestMethodExecutor.java:234)

                at org.jboss.arquillian.container.test.impl.execution.RemoteTestExecuter.execute(RemoteTestExecuter.java:109)

             

            Following is my getDeployment method now.

             

                @Deployment

                @Dependencies({

                        @AddonDependency(name = "org.codehaus.griffon.forge:griffon-forge-addon"),

                        @AddonDependency(name="org.jboss.forge.furnace.container:cdi")

                })

                public static ForgeArchive getDeployment() {

                    ForgeArchive archive = ShrinkWrap.create(ForgeArchive.class)

                                                    .addBeansXML()

                                                    .addAsAddonDependencies(

                                            AddonDependencyEntry.create("org.codehaus.griffon.forge:griffon-forge-addon"),

                                            AddonDependencyEntry.create("org.jboss.forge.furnace.container:cdi") );

                    return archive;

                }

             

            Thanks

            Buddha