Currently We're using TDD and planing to migrate into BDD using Jbehave. I just done some google search and not able to find any site for testNG with Jbehave. I just went through the Jbehave official site where I understood that possible to integrate the jbehave library with any type of unit testing tool like TestNg, Junit. But I didn't find any sample code that how to actually do it. I'm expecting the following steps from some experts:
- How to create a simple java file with Jbehave+TestNG.
Is it possible to use all the features of TestNG after I implemented with Jbehave(Like, annotations. BeforeClass, afterClass, BeforeSuite, AfterSuite)
How to run the Jbehave feature file/class through TestNG.xml file.
How to integrate custom test report in Jbehave?
I'm really not expecting any practical example or working code. I just wanna the understand the overview journey, and some inputs to achieve this task.
Its really helpful If some one share link, and very basic code which makes me more clear on that.
The following things so far I tried :
Feature file:
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
Test step class file:
public class GoogleSearchEngine_Steps {
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']/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();
}
}
But stuck to create a test runner class file using TestNg. I'm not sure How to start.
Can somebody help me to create a test runner class file which will execute the above code.
I read some of the materials but I don't have sufficient time to read all those, and implement It would be highly thankful If some one help me out.