This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package services; | |
public class RealGreetingService implements GreetingService { | |
@Override | |
public String greeting() { | |
return "bonjour"; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package services; | |
public interface GreetingService { | |
String greeting(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name := "sample-play-with-guice" | |
version := "1.0-SNAPSHOT" | |
libraryDependencies ++= Seq( | |
javaJdbc, | |
javaEbean, | |
cache, | |
"com.google.inject" % "guice" % "4.0-beta" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
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$") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
guiceModule=CucumberModule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |