arquillian / arquillian-cube

Control (docker, kubernetes, openshift) containers in your tests with ease!
http://arquillian.org/arquillian-cube/
121 stars 98 forks source link

Running with Cukespace class results in running the tests 4 times #707

Closed RajAsapu closed 7 years ago

RajAsapu commented 7 years ago

Environment: testCompile group: 'junit', name: 'junit', version: '4.11' compile group: 'org.hamcrest', name: 'hamcrest-core', version: '1.3' compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.0' compile group: 'info.cukes', name: 'cucumber-java', version: '1.2.5' compile group: 'com.github.cukespace', name: 'cukespace-core', version: '1.6.3' compile group: 'org.seleniumhq.selenium', name: 'selenium-server', version: '3.4.0' compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.4.0' compile group: 'org.seleniumhq.selenium', name: 'selenium-htmlunit-driver', version: '2.52.0' compile group: 'net.masterthought', name: 'cucumber-reporting', version: '3.7.0' compile group: 'log4j', name: 'log4j', version: '1.2.17' compile 'io.rest-assured:xml-path:3.0.2' testCompile group: 'org.mockito', name: 'mockito-all', version: '2.0.2-beta' testCompile group: 'com.github.docker-java', name: 'docker-java', version: '3.0.9' testCompile group: 'io.rest-assured', name: 'rest-assured', version: '3.0.0' testCompile group: 'com.jayway.jsonpath', name: 'json-path', version: '2.2.0' compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.8.7' compile group: 'org.jboss.arquillian.junit', name: 'arquillian-junit-standalone', version: '1.1.12.Final' compile group: 'org.arquillian.cube', name: 'arquillian-cube-docker', version: '1.1.0'

Test Runner : Below is the code which brings the containers and runs the cucumber `tests``package runner;

import com.google.common.base.Verify; import cucumber.api.CucumberOptions; import cucumber.api.java.After; import cucumber.runtime.arquillian.CukeSpace; import junit.runner.TestRunListener; import net.masterthought.cucumber.Configuration; import net.masterthought.cucumber.ReportBuilder; import net.masterthought.cucumber.Reportable; import org.arquillian.cube.CubeIp; import org.arquillian.cube.HostPort; import org.arquillian.cube.docker.impl.requirement.RequiresDocker; import org.jboss.arquillian.container.test.api.RunAsClient; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Rule; import org.junit.runner.RunWith; import setup.UpdateProperties; import java.io.File; import java.lang.annotation.Repeatable; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map;

@CucumberOptions( strict = true, plugin = {"html:target/cucumber-html-report"}, features = {"src/test/resources/features/pageobjects/"}, glue = {"classpath:"}, tags = {"@TestData1"} ) @RunWith(CukeSpace.class) @RunAsClient

public class RunTest {

@CubeIp(containerName = "database")
protected String ipDatabase;

private UpdateProperties props = new UpdateProperties();
private Map<String, String> map = new HashMap<String, String>();

@BeforeClass
public void initialization() throws Exception {
    if (props.getEnv().equalsIgnoreCase("docker")) {
        Verify.verify(props.startServiceContainer(ipDatabase, "epe-config:latest"));
        props.setProperty(map);
        props.updateHostConfig();
        System.out.println("Arquillian - Containers has started .");
    }
}

@AfterClass
public void generateReports()
{
    File reportOutputDirectory = new File("target");
    List<String> jsonFiles = new ArrayList<>();
    jsonFiles.add("target/cucumber-report/runner.RunTest.json");

    String buildNumber = "1";
    String projectName = "Pricing-e2e-tests";
    boolean parallelTesting = false;

    Configuration configuration = new Configuration(reportOutputDirectory, projectName);
    configuration.setParallelTesting(false);
    configuration.setBuildNumber(buildNumber);

    configuration.addClassifications("Platform", "Linux");
    configuration.addClassifications("Browser", "Phantom JS");

    ReportBuilder reportBuilder = new ReportBuilder(jsonFiles, configuration);
    Reportable result = reportBuilder.generateReports();

}

}

`

lordofthejars commented 7 years ago

Strange, can you ping cukes guys too? We are not affecting the test execution flow, but of course I might be wrong

El 23 may. 2017 7:59 p. m., "R@j $ekh@r" notifications@github.com escribió:

Environment: testCompile group: 'junit', name: 'junit', version: '4.11' compile group: 'org.hamcrest', name: 'hamcrest-core', version: '1.3' compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.0' compile group: 'info.cukes', name: 'cucumber-java', version: '1.2.5' compile group: 'com.github.cukespace', name: 'cukespace-core', version: '1.6.3' compile group: 'org.seleniumhq.selenium', name: 'selenium-server', version: '3.4.0' compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.4.0' compile group: 'org.seleniumhq.selenium', name: 'selenium-htmlunit-driver', version: '2.52.0' compile group: 'net.masterthought', name: 'cucumber-reporting', version: '3.7.0' compile group: 'log4j', name: 'log4j', version: '1.2.17' compile 'io.rest-assured:xml-path:3.0.2' testCompile group: 'org.mockito', name: 'mockito-all', version: '2.0.2-beta' testCompile group: 'com.github.docker-java', name: 'docker-java', version: '3.0.9' testCompile group: 'io.rest-assured', name: 'rest-assured', version: '3.0.0' testCompile group: 'com.jayway.jsonpath', name: 'json-path', version: '2.2.0' compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.8.7' compile group: 'org.jboss.arquillian.junit', name: 'arquillian-junit-standalone', version: '1.1.12.Final' compile group: 'org.arquillian.cube', name: 'arquillian-cube-docker', version: '1.1.0'

Test Runner : Below is the code which brings the containers and runs the cucumber `tests``package runner;

import com.google.common.base.Verify; import cucumber.api.CucumberOptions; import cucumber.api.java.After; import cucumber.runtime.arquillian.CukeSpace; import junit.runner.TestRunListener; import net.masterthought.cucumber.Configuration; import net.masterthought.cucumber.ReportBuilder; import net.masterthought.cucumber.Reportable; import org.arquillian.cube.CubeIp; import org.arquillian.cube.HostPort; import org.arquillian.cube.docker.impl.requirement.RequiresDocker; import org.jboss.arquillian.container.test.api.RunAsClient; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Rule; import org.junit.runner.RunWith; import setup.UpdateProperties; import java.io.File; import java.lang.annotation.Repeatable; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map;

@cucumberoptions( strict = true, plugin = {"html:target/cucumber-html-report"}, features = {"src/test/resources/features/pageobjects/"}, glue = {"classpath:"}, tags = {"@testdata1"} ) @runwith(CukeSpace.class) @runasclient

public class RunTest {

@CubeIp(containerName = "database") protected String ipDatabase;

private UpdateProperties props = new UpdateProperties(); private Map<String, String> map = new HashMap<String, String>();

@BeforeClass public void initialization() throws Exception { if (props.getEnv().equalsIgnoreCase("docker")) { Verify.verify(props.startServiceContainer(ipDatabase, "epe-config:latest")); props.setProperty(map); props.updateHostConfig(); System.out.println("Arquillian - Containers has started ."); } }

@AfterClass public void generateReports() { File reportOutputDirectory = new File("target"); List jsonFiles = new ArrayList<>(); jsonFiles.add("target/cucumber-report/runner.RunTest.json");

String buildNumber = "1";
String projectName = "Pricing-e2e-tests";
boolean parallelTesting = false;

Configuration configuration = new Configuration(reportOutputDirectory, projectName);
configuration.setParallelTesting(false);
configuration.setBuildNumber(buildNumber);

configuration.addClassifications("Platform", "Linux");
configuration.addClassifications("Browser", "Phantom JS");

ReportBuilder reportBuilder = new ReportBuilder(jsonFiles, configuration);
Reportable result = reportBuilder.generateReports();

}

}

`

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/arquillian/arquillian-cube/issues/707, or mute the thread https://github.com/notifications/unsubscribe-auth/ABcmYXDPtb2iLngCTIH8m1CZGA67vgHQks5r8x6egaJpZM4NkD9f .

RajAsapu commented 7 years ago

It behaves in the same way even though i run with Arquillian.class(Skipping cucumber tests) .I see that its iterating at the below code and interceptors returns size as 4(I am not sure what does that mean). I am running my test on Intellij and when i debug it is iterating thru this multiple times(4 times instead of one).

class name : EventContextImpl.java

`   @Override
   public void proceed()
   {

      if(currentInterceptor == interceptors.size())
      {
         invokeObservers();
         invokeNonManagedObserver();
      }
      else
      {
         ObserverMethod interceptor = interceptors.get(currentInterceptor++);
         manager.debug(interceptor, true);
         interceptor.invoke(manager, this);
      }
   }

   private void invokeObservers()
   {
      for(ObserverMethod observer : observers)
      {
         try
         {
            manager.debug(observer, false);
            observer.invoke(manager, event);
         } 
         catch (InvocationException e) 
         {
            Throwable cause = e.getCause();
            if(manager.isExceptionHandled(cause))
            {
               UncheckedThrow.throwUnchecked(cause);
            }
            else
            {
               manager.fireException(cause);
            }
         }
      }
   }`
lordofthejars commented 7 years ago

Can you share a full github project to check exactly what s happening? Never saw this in cube before

El 23 may. 2017 8:19 p. m., "R@j $ekh@r" notifications@github.com escribió:

It behaves in the same way even though i run with Arquillian.class . By the what does interceptors in the below code mean .. I am running my test on Intellij and when i debug it is iterating thru this multiple times(4 times instead of one).

class name : EventContextImpl.java

` @Override public void proceed() {

  if(currentInterceptor == interceptors.size())
  {
     invokeObservers();
     invokeNonManagedObserver();
  }
  else
  {
     ObserverMethod interceptor = interceptors.get(currentInterceptor++);
     manager.debug(interceptor, true);
     interceptor.invoke(manager, this);
  }

}

private void invokeObservers() { for(ObserverMethod observer : observers) { try { manager.debug(observer, false); observer.invoke(manager, event); } catch (InvocationException e) { Throwable cause = e.getCause(); if(manager.isExceptionHandled(cause)) { UncheckedThrow.throwUnchecked(cause); } else { manager.fireException(cause); } } } }`

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/arquillian/arquillian-cube/issues/707#issuecomment-303487980, or mute the thread https://github.com/notifications/unsubscribe-auth/ABcmYVkcXud7Xag50ia2LhsLT4wxlVisks5r8yM7gaJpZM4NkD9f .

RajAsapu commented 7 years ago

I am getting the issue when i am running with cukespace 1.6.3 , on upgrading cukespace to 1.6.7 it got solved.