net.serenitybdd.core.exceptions.StepInitialisationException: -> Google steps

3,274 views
Skip to first unread message

Hector Menchaca

unread,
Mar 30, 2017, 9:27:49 AM3/30/17
to Serenity BDD Users Group
I getting an error:
net.serenitybdd.core.exceptions.StepInitialisationException: Failed to create step library for GoogleSteps:java.lang.NullPointerException-->null
at net.thucydides.core.steps.StepFactory.getNewStepLibraryFor(StepFactory.java:84)
looks like a cglib issue

<serenity.version>1.2.3-rc.4</serenity.version>
<serenity.cucumber.version>1.1.27</serenity.cucumber.version>


I have other test in the suite... headless, no managed browser and all the steps load fine.

Any thoughts?

I created this to reproduce...

GoogTest->

public static AbstractApplicationContext context = MtafContextConfiguration.getAnnotationConfigApplicationContext();
public static Boolean isBeforeClass = false;

@Managed
public WebDriver driver;
@Steps
public GoogleSteps googleSteps;
@Before
public void setup() throws WebDriverException, TestDataException{
if(isBeforeClass){
googleSteps.start();
isBeforeClass = false;
}
}
@Test
@Title("User searches for text")
public void user_navigates_successfully_UA_N() {

googleSteps.searchForText("Optimus Prime");
}
public static TestStatus testStatus;

 @Rule
 public TestWatcher watchman= new TestWatcher() {
     @Override
     protected void failed(Throwable e, Description description) {
     testStatus = TestStatus.FAILED;
     }
     @Override
     protected void succeeded(Description description) {
     testStatus = TestStatus.PASSED;
     }
   };

GoogleSteps->


public class GoogleSteps {

@Steps
GooglePage googlePage = null;
public GoogleSteps(){
assertThat( googlePage.getDriver() ).isEqualTo( false ); 
}
@Step("Driver is not null")
public void driverIsNotnull(){
}
@Step("Start Google")
public void start(){
googlePage.setUpPage();
}

@Step("Search for {0}")
public void searchForText(String text){
googlePage.searchForText(text);
}

}

Google Page->

public class GooglePage extends PageObject implements ILoggable {
private static String SEARCH = "#lst-ib";

public GooglePage()  {
}

public void setUpPage() {
String url = WebCommon.Google.getUrl().toLowerCase();
if(!this.getDriver().getCurrentUrl().toLowerCase().contains( url  ) ){
this.getDriver().manage().window().maximize();
this.openAt( url );

}
}
private PageObject me(){
return this;
}
public boolean isDriverNull(){
return this.getDriver() == null ? true : false;
}
public void searchForText(String text){
$(SEARCH).waitUntilVisible().then().typeAndEnter( text );

}
}


-------------------------------------------------------------------------------
Test set: com.nokia.mtaf.web.serenity.junit.GoogleTest
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.792 sec <<< FAILURE! - in com.nokia.mtaf.web.serenity.junit.GoogleTest
com.nokia.mtaf.web.serenity.junit.GoogleTest  Time elapsed: 0.87 sec  <<< ERROR!
net.serenitybdd.core.exceptions.StepInitialisationException: Failed to create step library for GoogleSteps:java.lang.NullPointerException-->null
at net.thucydides.core.steps.StepFactory.getNewStepLibraryFor(StepFactory.java:84)
at net.thucydides.core.steps.StepFactory.getStepLibraryFor(StepFactory.java:76)
at net.thucydides.core.steps.StepAnnotations.instantiateAnyUnitiaializedSteps(StepAnnotations.java:52)
at net.thucydides.core.steps.StepAnnotations.instanciateScenarioStepFields(StepAnnotations.java:41)
at net.thucydides.core.steps.StepAnnotations.injectScenarioStepsInto(StepAnnotations.java:23)
at net.serenitybdd.junit.runners.SerenityRunner.injectScenarioStepsInto(SerenityRunner.java:597)
at net.serenitybdd.junit.runners.SerenityRunner.methodInvoker(SerenityRunner.java:561)
at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:273)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at net.serenitybdd.junit.runners.SerenityRunner.performRunChild(SerenityRunner.java:470)
at net.serenitybdd.junit.runners.SerenityRunner.runChild(SerenityRunner.java:445)
at net.serenitybdd.junit.runners.SerenityRunner.runChild(SerenityRunner.java:54)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at net.serenitybdd.junit.runners.SerenityRunner.run(SerenityRunner.java:251)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:283)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:173)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:128)
at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
Caused by: net.sf.cglib.core.CodeGenerationException: java.lang.NullPointerException-->null
at net.sf.cglib.core.ReflectUtils.newInstance(ReflectUtils.java:235)
at net.sf.cglib.core.ReflectUtils.newInstance(ReflectUtils.java:220)
at net.sf.cglib.core.ReflectUtils.newInstance(ReflectUtils.java:216)
at net.sf.cglib.proxy.Enhancer.createUsingReflection(Enhancer.java:643)
at net.sf.cglib.proxy.Enhancer.firstInstance(Enhancer.java:538)
at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:225)
at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:377)
at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:285)
at net.thucydides.core.steps.StepFactory.createProxyStepLibrary(StepFactory.java:180)
at net.thucydides.core.steps.StepFactory.instantiateNewStepLibraryFor(StepFactory.java:125)
at net.thucydides.core.steps.StepFactory.instantiateNewStepLibraryFor(StepFactory.java:117)
at net.thucydides.core.steps.StepFactory.getNewStepLibraryFor(StepFactory.java:82)
at net.thucydides.core.steps.StepFactory.getStepLibraryFor(StepFactory.java:76)
at net.thucydides.core.steps.StepAnnotations.instantiateAnyUnitiaializedSteps(StepAnnotations.java:52)
at net.thucydides.core.steps.StepAnnotations.instanciateScenarioStepFields(StepAnnotations.java:41)
at net.thucydides.core.steps.StepAnnotations.injectScenarioStepsInto(StepAnnotations.java:23)
at net.serenitybdd.junit.runners.SerenityRunner.injectScenarioStepsInto(SerenityRunner.java:597)
at net.serenitybdd.junit.runners.SerenityRunner.methodInvoker(SerenityRunner.java:561)
at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:273)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at net.serenitybdd.junit.runners.SerenityRunner.performRunChild(SerenityRunner.java:470)
at net.serenitybdd.junit.runners.SerenityRunner.runChild(SerenityRunner.java:445)
at net.serenitybdd.junit.runners.SerenityRunner.runChild(SerenityRunner.java:54)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at net.serenitybdd.junit.runners.SerenityRunner.run(SerenityRunner.java:251)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:283)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:173)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:128)
at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
Caused by: java.lang.NullPointerException: null
at com.nokia.mtaf.web.serenity.junit.GoogleSteps.<init>(GoogleSteps.java:20)
at com.nokia.mtaf.web.serenity.junit.GoogleSteps$$EnhancerByCGLIB$$5f32bde7.<init>(<generated>)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at net.sf.cglib.core.ReflectUtils.newInstance(ReflectUtils.java:228)
at net.sf.cglib.core.ReflectUtils.newInstance(ReflectUtils.java:220)
at net.sf.cglib.core.ReflectUtils.newInstance(ReflectUtils.java:216)
at net.sf.cglib.proxy.Enhancer.createUsingReflection(Enhancer.java:643)
at net.sf.cglib.proxy.Enhancer.firstInstance(Enhancer.java:538)
at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:225)
at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:377)
at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:285)
at net.thucydides.core.steps.StepFactory.createProxyStepLibrary(StepFactory.java:180)
at net.thucydides.core.steps.StepFactory.instantiateNewStepLibraryFor(StepFactory.java:125)
at net.thucydides.core.steps.StepFactory.instantiateNewStepLibraryFor(StepFactory.java:117)
at net.thucydides.core.steps.StepFactory.getNewStepLibraryFor(StepFactory.java:82)
at net.thucydides.core.steps.StepFactory.getStepLibraryFor(StepFactory.java:76)
at net.thucydides.core.steps.StepAnnotations.instantiateAnyUnitiaializedSteps(StepAnnotations.java:52)
at net.thucydides.core.steps.StepAnnotations.instanciateScenarioStepFields(StepAnnotations.java:41)
at net.thucydides.core.steps.StepAnnotations.injectScenarioStepsInto(StepAnnotations.java:23)
at net.serenitybdd.junit.runners.SerenityRunner.injectScenarioStepsInto(SerenityRunner.java:597)
at net.serenitybdd.junit.runners.SerenityRunner.methodInvoker(SerenityRunner.java:561)
at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:273)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at net.serenitybdd.junit.runners.SerenityRunner.performRunChild(SerenityRunner.java:470)
at net.serenitybdd.junit.runners.SerenityRunner.runChild(SerenityRunner.java:445)
at net.serenitybdd.junit.runners.SerenityRunner.runChild(SerenityRunner.java:54)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at net.serenitybdd.junit.runners.SerenityRunner.run(SerenityRunner.java:251)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:283)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:173)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:128)
at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)

John Smart

unread,
Mar 30, 2017, 9:30:30 AM3/30/17
to Hector Menchaca, Serenity BDD Users Group
In this code:

public class GoogleSteps {

@Steps
GooglePage googlePage = null;
public GoogleSteps(){
assertThat( googlePage.getDriver() ).isEqualTo( false ); 
}

Try removing the @Steps annotation and not setting the field to null.

--
You received this message because you are subscribed to the Google Groups "Serenity BDD Users Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to thucydides-users+unsubscribe@googlegroups.com.
To post to this group, send email to thucydides-users@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
___________________________________________________
John Smart | Wakaleo Consulting  |  +44 7398 832273
Making smart teams collaborate better
http://johnfergusonsmart.com  |  john....@wakaleo.com
___________________________________________________

We love breaking down silos and helping smart teams collaborate better! Ask about our tailored on-site workshops in Agile Product Planning, BDD Requirements Discovery,  BDD, TDD and Clean Coding, and Advanced BDD Test Automation.

Need some help with Serenity BDD? Check out our Serenity BDD training and support packages here.
___________________________________________________

Hector Menchaca

unread,
Mar 30, 2017, 9:45:09 AM3/30/17
to Serenity BDD Users Group, hm3...@hotmail.com
 I did as you said... same issue... I do appreciate the response
To unsubscribe from this group and stop receiving emails from it, send an email to thucydides-use...@googlegroups.com.
To post to this group, send email to thucydid...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Hector Menchaca

unread,
Mar 30, 2017, 9:48:54 AM3/30/17
to Serenity BDD Users Group, hm3...@hotmail.com
idiot me...

I figured it out

I have code in the default constructor as opposed to the method it belongs in
Reply all
Reply to author
Forward
0 new messages