2 Replies Latest reply on Mar 30, 2013 9:23 AM by Alphonse Bendt

    is it possible to skip the arquillian lifecycle programatically?

    Alphonse Bendt Newbie

      Hi all,

       

      we often use arquillian in client mode (@Deployment(testable = false)). While working on a test, it's often helpful, to run the test against an already deployed application.

      This does not seem to be possible with arquillian. Right now we are commenting out the @RunWith temporarily. This is not a good solution because sometimes then a commented out @RunWith is checked in which causes the tests to fail on jenkins etc.

       

      I would like to be able to define a configuration (e.g. sysproperty in my IDE). if this is set and picked up by arquillian container startup and/or deployment is skipped by arquillian.

       

      is this somehow possible?

       

      best regards,

         Alphonse Bendt

        • 1. Re: is it possible to skip the arquillian lifecycle programatically?
          Karel Piwko Master

          Well, it is not possible out of the box. You have two possibilities I can think of from the top of my head:

           

          You set deployment mode to manual, and you deploy manually:

           

          @Deployment(name = "X", managed = false, testable = false)
          public static WebArchive manualDeployment() {
             
          return ShrinkWrap.create(WebArchive.class)....
          }

           

          @ArquillianResource Deployer deployer;

           

          @Test @InSequence(1)
          public void shouldBeAbleToDeploy() {

             if(deploy is enabled by system property) {
              deployer
          .deploy("X");

            }
          }

          @Test @InSequence(2) @OperateOnDeployment("X")
          public void shouldNowBeInDeploymentX() {
             
          // we're now inside X
          }

           

          Note, you should also handle @ArquillianResource URL somehow.

           

          Or, you write an extension that will modify Deployment Scenarios.

           

          Karel

          1 of 1 people found this helpful
          • 2. Re: is it possible to skip the arquillian lifecycle programatically?
            Alphonse Bendt Newbie

            Hi Karel,

             

            thanks a lot for your reply.

             

            I did not try out setting the deployment mode to manual because i'm more interested in skipping the whole container lifecycle.

            Here's what i did:

             

            i wrote an extension of jboss-as-arquillian-container-managed that installs a NoOpContainer if a specific system property is set:

             

             

            {code}

            public class NoOpContainerExtension implements LoadableExtension {

             

                @Override

                public void register(ExtensionBuilder builder) {

                    boolean skipContainerLifecycle = Boolean.parseBoolean(System.getProperty("arquillian.skipContainerLifecycle", "false"));

             

                    if (skipContainerLifecycle) {

                        builder.service(DeployableContainer.class, NoOpContainer.class);

                    } else {

                        new ManagedContainerExtension().register(builder);

                    }

                }

            }

            {code}

             

            In my IDE i set this variable to true to skip the arquillian lifecycle. Running the tests with Maven starts the container as usual.

             

            For reference you can find the code here: https://github.com/abendt/jboss-as-arquillian-container-noop

             

            best Regards,

               Alphonse Bendt