Skip to content

Instantly share code, notes, and snippets.

import com.google.inject.AbstractModule;
import com.google.inject.name.Names;
import play.test.TestBrowser;
import play.test.TestServer;
import static play.test.Helpers.*;
public class CucumberModule extends AbstractModule {
private static int PORT = 3333;
private TestServer testServer = testServer(PORT, fakeApplication(inMemoryDatabase()));
private TestBrowser testBrowser = testBrowser(HTMLUNIT, PORT);
name := "sample-with-cucumber"
version := "1.0-SNAPSHOT"
libraryDependencies ++= Seq(
javaJdbc,
javaEbean,
cache,
"com.google.inject" % "guice" % "3.0" % "test",
"info.cukes" % "cucumber-guice" % "1.1.5" % "test",
1 Scenarios (1 passed)
3 Steps (3 passed)
0m3.544s
@(message: String)
@main("Cucumber") {
@play20.welcome(message, style = "Java")
}
...
0m[error] Test Scenario: Cucumber Integration failed: expected:<'[Cucumber]'> but was:<'[Welcome to Play]'>
...
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
import static org.fest.assertions.Assertions.assertThat;
public class Steps {
@Given("^I have setup Play$")
public void I_have_setup_Play() throws Throwable {
}
import cucumber.api.java.Before;
import play.test.TestBrowser;
import play.test.TestServer;
import static play.test.Helpers.*;
public class GlobalHooks {
public static int PORT = 3333;
public static TestBrowser TEST_BROWSER;
private static TestServer TEST_SERVER;
private static boolean initialised = false;
import cucumber.api.java.Before;
import play.test.TestBrowser;
import play.test.TestServer;
import static play.test.Helpers.*;
public class GlobalHooks {
public static int PORT = 3333;
public static TestBrowser TEST_BROWSER;
private static TestServer TEST_SERVER;
private static boolean initialised = false;
...
You can implement missing steps with the snippets below:
@Given("^I have setup Play$")
public void I_have_setup_Play() throws Throwable {
// Express the Regexp above with the code you wish you had
throw new PendingException();
}
@When("^I go to the landing page$")