Help working with two step classes


#1

I am trying to create a proof of concept in Cucumber/Java/Selenium and I am a horrible java developer (see prior post where I am seeking one). I have an existing Cucumber/Java/Selenium project where there is just a feature file and a step definitions file and this snippet brings up google home page as expected:

public class StepDefinitions {
	
    WebDriver driver;

    @Before
    public void setup() {
    	System.setProperty("webdriver.firefox.marionette", "/usr/local/bin/geckodriver");
    	this.driver = new FirefoxDriver();
    	this.driver.manage().window().maximize();
    	this.driver.manage().timeouts().pageLoadTimeout(60, TimeUnit.SECONDS);
    }
    @When("^I navigate to Google$")
    public void iNavigateToGoogle() {
    	driver.get("https://www.google.com/");
     }
}

When I use HipTest published it generates 2 step classes: a StepDefinitions class that creates a ActionWords class. My StepDefinitions looks like this:

public class StepDefinitions {
    public Actionwords actionwords = new Actionwords();
    
    @When("^I navigate to Google$")
    public void iNavigate to Google() {
        actionwords.iNavigateToGoogle();
    }
}

But when I put my @Before block at the top of the Actionwords class the browser loads blank and returns a null pointer exception

public class Actionwords {
	
    WebDriver driver;

    @Before
    public void setup() {
    	System.setProperty("webdriver.firefox.marionette", "/usr/local/bin/geckodriver");
    	this.driver = new FirefoxDriver();
    	this.driver.manage().window().maximize();
    	this.driver.manage().timeouts().pageLoadTimeout(60, TimeUnit.SECONDS);
    }
    
    public void iNavigateToGoogle() {
    	driver.get("https://www.google.com/");
     }
}

How do I structure this? Does someone have a working example of Cucumber/Java/Selenium that works with HipTest that I can look at?