Uploaded image for project: 'Arquillian'
  1. Arquillian
  2. ARQ-1345

maxTestClassesBeforeRestart causes more restarts than it should

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 1.0.4.Final
    • 1.0.3.Final
    • None
    • None

      ContainerRestarter (package org.jboss.arquillian.container.test.impl.client.container) has a bug in it that causes maxTestClassesBeforeRestart to be evaluated slightly incorrectly. The below code is what the shouldRestart() method currently does:

            ArquillianDescriptor descriptor = configuration.get(); 
            Integer maxTestClasses = descriptor.engine().getMaxTestClassesBeforeRestart();
            if(maxTestClasses == null)
            {
               return false;
            }
            if(maxTestClasses > -1) 
            {
               if((maxTestClasses -1 ) == testClassesCount)
               {
                  testClassesCount = 0;
                  return true;
               }
            }
            testClassesCount++;
            return false;
      

      Because it checks if maxTestClasses - 1 is equal to testClassesCount, the first container restart actually occurs before test #N-1, not test #N. An easy way to see this is to set maxTestClassesBeforeRestart to 1; you will observe that the container is started for the first time, then immediately shut down without anything being deployed, then restarted.

      This can be fixed by checking if maxTestClasses == testClassesCount instead of maxTestClasses - 1 == testClassesCount.

              aslak@redhat.com Aslak Knutsen
              rdicroce Richard DiCroce (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: