Understanding BDD with intern framework

183 Views Asked by At

I am currently using intern with karma, TDD style. I want to switch to cucumber but it has been pretty difficult, as my project is extremely large and is already configured a certain way. I began thinking about using BDD with intern instead as it would be much easier, and I was wondering about how similar I can make BDD to Gherkin syntax?

Particularly, I like how you can specify {int} or {word} in cucumber step files. Is there anyway to do something similar in intern?

Any feedback on how close intern-bdd is to Gherkin/Cucumber would be very helpful.

2

There are 2 best solutions below

0
Shubham Jain On

For Integer you can do something like:

@When("^When user is on the error \"(\\d+)\" page$")
public void When_user_is_on_the_error_page(int errorNum) throws Throwable {

...

}

OR

Feature:

Scenario: Some cukes
Given I have 48 cukes in my belly

   @Given("I have {int} cukes in my belly")
    public void i_have_n_cukes_in_my_belly(int cukes) {
        System.out.format("Cukes: %n\n", cukes);
    }
}

Source:

https://cucumber.io/docs/cucumber/step-definitions/

How to write numbers in cucumber scenarios

For String

Feature:

When search for one-way flights between "Bengaluru" and "Mumbai"

@When("^search for one-way flights between \"([^\"]*)\" and \"([^\"]*)\"$")
public void search_for_one_way_flights_between_source_and_destination(String source, String destination) throws Throwable {

 .......
}
10
jason0x43 On

Intern’s built-in bdd interface is similar to that of other JS testing systems, and is essentially just a different syntax for its tdd interface (describe and it vs suite and test). There’s no relation to Cucumber syntax.

There is an intern-cucumber plug-in that supports cucumber syntax, if you’d like to try that.