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

maxTestClassesBeforeRestart causes more restarts than it should

    XMLWordPrintable

Details

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

    Description

      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.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: