-
Notifications
You must be signed in to change notification settings - Fork 255
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #68 from SERG-Delft/cucumber
Added a simple Cucumber test.
- Loading branch information
Showing
6 changed files
with
153 additions
and
8 deletions.
There are no files selected for viewing
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
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
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
24 changes: 24 additions & 0 deletions
24
src/test/java/nl/tudelft/jpacman/cucumber/CucumberTest.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package nl.tudelft.jpacman.cucumber; | ||
|
||
import cucumber.api.CucumberOptions; | ||
import cucumber.api.SnippetType; | ||
import cucumber.api.junit.Cucumber; | ||
import org.junit.runner.RunWith; | ||
|
||
/** | ||
* Entry point for running the the Cucumber tests in JUnit. | ||
* | ||
* @author Jan-Willem Gmelig Meyling | ||
*/ | ||
@RunWith(Cucumber.class) | ||
@CucumberOptions( | ||
plugin = {"pretty"}, | ||
snippets = SnippetType.CAMELCASE, | ||
features = "classpath:features") | ||
public class CucumberTest { | ||
|
||
/** | ||
* This class should be empty, step definitions should be in separate classes. | ||
*/ | ||
|
||
} |
74 changes: 74 additions & 0 deletions
74
src/test/java/nl/tudelft/jpacman/cucumber/StateNavigationSteps.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package nl.tudelft.jpacman.cucumber; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
import cucumber.api.java.After; | ||
import cucumber.api.java.en.Given; | ||
import cucumber.api.java.en.Then; | ||
import cucumber.api.java.en.When; | ||
import nl.tudelft.jpacman.Launcher; | ||
import nl.tudelft.jpacman.game.Game; | ||
|
||
/** | ||
* Step definitions for the Cucumber tests. | ||
* | ||
* The steps also support setting up a {@link Game} object | ||
* which other tests can use for further testing the game. | ||
* | ||
* @author Jan-Willem Gmelig Meyling, Arie van Deursen | ||
*/ | ||
public class StateNavigationSteps { | ||
|
||
private static Game theGame; | ||
|
||
private Launcher launcher; | ||
|
||
/** | ||
* The Game created by the tests. | ||
* | ||
* @return Game created when starting up the game. Null if game has not been launched. | ||
*/ | ||
public static Game getGame() { | ||
return theGame; | ||
} | ||
|
||
private static void setGame(Game game) { | ||
theGame = game; | ||
} | ||
|
||
/** | ||
* Launch the game. This makes the game available via | ||
* the {@link getGame} method. | ||
*/ | ||
@Given("^the user has launched the JPacman GUI$") | ||
public void theUserHasLaunchedTheJPacmanGUI() { | ||
launcher = new Launcher(); | ||
launcher.launch(); | ||
|
||
setGame(launcher.getGame()); | ||
} | ||
|
||
/** | ||
* Start playing the game. | ||
*/ | ||
@When("^the user presses the \"Start\" button$") | ||
public void theUserPressesStart() { | ||
getGame().start(); | ||
} | ||
|
||
/** | ||
* Verify that the play is actually running. | ||
*/ | ||
@Then("^the game is running$") | ||
public void theGameShouldStart() { | ||
assertTrue(getGame().isInProgress()); | ||
} | ||
|
||
/** | ||
* Close the UI after all tests are finished. | ||
*/ | ||
@After | ||
public void tearDownUI() { | ||
launcher.dispose(); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Feature: 1. Startup | ||
As a player | ||
I want to start the game | ||
so that I can actually play | ||
|
||
Scenario: S1.1 Startup | ||
Given the user has launched the JPacman GUI | ||
When the user presses the "Start" button | ||
Then the game is running |