Skip to content

Instantly share code, notes, and snippets.

package controllers;
import com.google.inject.Inject;
import play.mvc.Controller;
import play.mvc.Result;
import services.GreetingService;
import views.html.index.*;
public class Application extends Controller {
package services;
public class RealGreetingService implements GreetingService {
@Override
public String greeting() {
return "bonjour";
}
}
package services;
public interface GreetingService {
String greeting();
}
name := "sample-play-with-guice"
version := "1.0-SNAPSHOT"
libraryDependencies ++= Seq(
javaJdbc,
javaEbean,
cache,
"com.google.inject" % "guice" % "4.0-beta"
)
import com.google.inject.Inject;
import com.google.inject.name.Named;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
import play.test.TestBrowser;
import static org.fest.assertions.Assertions.assertThat;
public class Steps {
@Inject
...
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$")
Feature: Testing Cucumber Integration
Scenario: Cucumber Integration # example.feature:3
Given I have setup Play # Steps.I_have_setup_Play()
When I go to the landing page # Steps.I_go_to_the_landing_page()
Then the title should be "Cucumber" # Steps.the_title_should_be(String)
1 Scenarios (1 passed)
3 Steps (3 passed)
0m2.092s
import com.google.inject.Inject;
import com.google.inject.name.Named;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
import play.test.TestBrowser;
import static org.fest.assertions.Assertions.assertThat;
public class Steps {
@Inject
import com.google.inject.Inject;
import cucumber.api.java.Before;
import play.test.TestBrowser;
import play.test.TestServer;
import static play.test.Helpers.*;
public class GlobalHooks {
@Inject
private TestBrowser testBrowser;
@Inject