I just created feature file which is open google and enter some values in search engine and validated the search result. Also, I created a steps class file which contains given, when, and then annotations. Now, I wanna create a test runner which is used to drive the steps class file according to story file. But In my case I wanna use TestNG instead of Junit framework. I googled there are several sites were explained how to integrate the Jbehave+Junit. But So, far I didn't find any site where is the combination of Jbehave+TestNG. Since I'm trying by myself I just need some clarity on this. Can somebody give me a sample code which help me to understand better.
Please find Sample Story:
scenario: Check the google search engine
Given : Open the google home page www.google.com
When : Enter test automation in search box
Then : Proper result should be displayed in results page
Steps class file:
import org.jbehave.core.annotations.Given;
import org.jbehave.core.annotations.Then;
import org.jbehave.core.annotations.When;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class GoogleSearchEngine {
public static WebDriver driver;
@Given("Open the google home page $url")
public static void openUrl(String url) throws Exception {
try {
driver = new FirefoxDriver();
driver.get(url);
} catch (Exception ex) {
ex.printStackTrace();
}
}
@When("Enter $searchKeyword in search box")
public static void searchKeyword(String searchKeyword) throws Exception {
try {
driver.findElement(By.xpath(".//*[@id='gs_htif0']")).sendKeys(searchKeyword);
driver.findElement(By.xpath(".//*[@id='tsf']/center/input[1]")).click();
} catch (Exception ex) {
ex.printStackTrace();
}
}
@Then("Proper result should be displayed in results page")
public static void result() throws Exception {
try {
driver.quit();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
Then I need to develop testrunner which used to drive the story file.
Can somebody help me to create a test runner class file using TestNG framework?