Поэтому мы использовали плагин Cucable для параллельного запуска наших тестов.Наш фреймворк (часть, вызывающая проблему) спроектирован следующим образом:
Класс DriverManager инициализирует драйвер с помощью метода initiateWebDriverInstance
.Мы вызываем этот метод из класса Hooks.Существует одна статическая instance
переменная, которая будет содержать ссылку на свой объект с инициализированным драйвером.
DriverManager.java
public class DriverManager
{
public static DriverManagerinstance; // instance variable for DriverManager
public WebDriver driver;
public static String browsername = "chrome";
public static DriverManager getInstance() {
if (instance == null) {
instance = new DriverManager();
}
return instance;
}
public void initiateWebDriverInstance(String browserName) {
//initializing chrome driver
driver.manage().window().maximize(); //this is executing fine
}
//some code
}
Hooks.java
public class Hooks {
@Before
public void setup() {
DriverManager.getInstance().initiateWebDriverInstance(DriverManager.browsername);
}
@After...
}
Page1Steps.java
public class Page1Steps extends WebSessionManager {
private WebDriver driver = WebSessionManager.getInstance().driver; //driver is null here only in Jenkins rest working fine
private C2CWebLibrary webLibrary = new C2CWebLibrary(driver); //this is C2CLandingSteps.java:20
//some code
}
Эти тесты работают нормально на моей локальной машине, но они производят это на машине Дженкинса -
java.lang.NullPointerException на com.cars24.library.C2CWebLibrary. (C2CWebLibrary.java:30) на шаге.нав org.picocontainer.injectors.ConstructorInjector $ 1.run (ConstructorInjector.java:342) в org.picocontainer.injectors.AbstractInjector $ ThreadLocalCyclicDependencyGuard.observe (AbstractInjector.java:270) в org.picocontainer.injectors.ConstructorInjector.getComponentInstance (ConstructorInjector.java:364Inject.FactInjectFact.Fact.InjectFactor.Java: 56) в org.picocontainer.behaviors.: 699) в org.picocontainer.DefaultPicoContainer.getComponent (DefaultPicoContainer.java:647) в org.picocontainer.DefaultPicoContainer.getComponent (DefaultPicoContainer.java:678) в cucumber.runtime.java.picocanceactj.Fava:40) в cucumber.runtime.java.JavaStepDefinition.execute (JavaStepDefinition.java:38) в cucumber.runtime.StepDefinitionMatch.runStep (StepDefinitionMatch.java: 37) в cucumber.runtime.Runtime.runStep (Runtime.java:300) в cucumber.runtime.model.StepContainer.runStep (StepContainer.java:44) в cucumber.runtime.model.StepContainer.runSteps (StepContainer.Java: 39) в cucumber.runtime.model.CucumberScenario.run (CucumberScenario.java:44) в cucumber.runtime.junit.ExecutionUnitRunner.run (ExecutionUnitRunner.java:102) в cucumber.runtime.junild.RunatureRunature.java: 63) на cucumber.runtime.junit.FeatureRunner.runChild (FeatureRunner.java:18) на org.junit.runners.ParentRunner $ 3.run (ParentRunner.java:290) на org.junit.runners.ParentRunner $ 1.расписание (ParentRunner.java:71) в org.junit.runners.ParentRunner.runChildren (ParentRunner.java:288) в org.junit.runners.ParentRunner.access $ 000 (ParentRunner.java:58) в org.junit.runners.ParentRunner $ 2.evaluate (ParentRunner.java:268) в org.junit.runners.ParentRunner.run (ParentRunner.java:363) в cucumber.runtime.junit.FeatureRunner.run (FeatureRunner.java:70) в cucumber.api.junit.Cucumber.runChild (Cucumber.java:95) в cucumber.api.junit.Cucumber.runChild (Cucumber.java:38) в org.junit.runners.ParentRunner $ 3.run (ParentRunner.java:290) в org.junit.runners.ParentRunner $ 1.schedule (ParentRunner.java:71) в org.junit.runners.ParentRunner.runChildren (ParentRunner.java:288) в org.junit.runners.ParentRunner.access $ 000 (ParentRunner.java:58) в или.runners.ParentRunner $ 2.evaluate (ParentRunner.java:268) вorg.junit.internal.runners.statements.RunBefores.evaluate (RunBefores.java:26) в org.junit.internal.runners.statements.RunAfters.evaluate (RunAfters.java:27) в org.junit.runners.ParentRunner.запустить (ParentRunner.java:363) в cucumber.api.junit.Cucumber.run (Cucumber.java:100) в org.junit.runner.JUnitCore.run (JUnitCore.java:137) в org.junit.runner.JUnitCore.run (JUnitCore.java:115) при org.testng.junit.JUnit4TestRunner.start (JUnit4TestRunner.java:82) в org.testng.junit.JUnit4TestRunner.run (JUnit4TestRunner.java:70) при org.testng.TestRunner $ 1.run (TestRunner.java:667) в org.testng.TestRunner.runJUnitWorkers (TestRunner.java:950) в org.testng.TestRunner.privateRunJUnit (TestRunner.java:698) в org.testng.TestRunner.Java: 599) в org.testng.SuiteRunner.runTest (SuiteRunner.java:380) в org.testng.SuiteRunner.runSequentially (SuiteRunner.java:375) в org.testng.SuiteRunner.privateRun (SuiteRunner.java3: 40)org.testng.SuiteRunner.run (SuiteRunner.java:289) в org.testng.SuiteRunnerWorker.runSuite (SuiteRunnerWorker.java:52) по адресу org.testng.SuiteRunnerWorker.run (SuiteRunnerWorker.java:86) по адресу org.testng.TestNG.runSuitesSequentially (TestNG.java:1301) в org.testng.Sun.java: 1226) в org.testng.TestNG.runSuites (TestNG.java:1144) в org.testng.TestNG.run (TestNG.java:1115) в org.apache.maven.surefire.testng.TestNGExecutor.run (TestNGExecutor.java:135) по адресу org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.executeSingleClass (TestNGDirectoryTestSuite.java:112) по адресу org.apache.maven.surefire.testng.TestNGDirectoryTexTirect () ().apache.maven.surefire.testng..ForkedBooter.runSuitesInProcess (ForkedBooter.java:345) в org.apache.maven.surefire.booter.ForkedBooter.execute (ForkedBooter.java:126) в org.apache.maven.surefire.booter.ForkedBooter.main (ForkedBooter.java:418)
Тесты отлично выполняются на моей локальной машине.Что может быть не так в этом?