Started work on cucumber tests. Trying to sort through threads, getting inconsistent results.

#story[1111] #pair[kre39,ptg19]
This commit is contained in:
Kusal Ekanayake
2017-08-07 17:54:34 +12:00
parent f97b18d594
commit 97696cc95b
8 changed files with 74 additions and 6 deletions
+12
View File
@@ -0,0 +1,12 @@
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;
/**
* Created by kre39 on 7/08/17.
*/
@RunWith(Cucumber.class)
@CucumberOptions(features = "src/test/java/features")
public class RunCucumberTests {
}
@@ -0,0 +1,5 @@
Feature: SailsToggle
Scenario: User toggles in sail
Given The game is running
When the user has pressed "shift"
Then the sails are "in"
@@ -16,13 +16,11 @@ public class BoatSailAnimationToggleTest {
private Yacht yacht;
@Before
public void setup() throws Exception{
yacht = new Yacht("Yacht", 1, "YACHT", "YAC", "Test Yacht", "NZ");
}
@Test
public void sailToggleTest() throws Exception {
assertFalse(yacht.getSailIn());
+51
View File
@@ -0,0 +1,51 @@
package steps;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
import seng302.gameServer.GameStages;
import seng302.gameServer.GameState;
import seng302.gameServer.MainServerThread;
import seng302.gameServer.server.messages.BoatActionMessage;
import seng302.gameServer.server.messages.BoatActionType;
import seng302.model.Yacht;
import seng302.visualiser.ClientToServerThread;
/**
* Created by kre39 on 7/08/17.
*/
public class ToggleSailSteps {
MainServerThread mst;
ClientToServerThread client;
boolean sailsIn = false;
long startTime;
private Yacht yacht;
@Given("^The game is running$")
public void the_game_is_running() throws Throwable {
mst = new MainServerThread();
client = new ClientToServerThread("localhost", 4942);
GameState.setCurrentStage(GameStages.RACING);
}
@When("^the user has pressed \"([^\"]*)\"$")
public void the_user_has_pressed(String arg1) throws Throwable {
startTime = System.currentTimeMillis();
if (arg1 == "shift") {
if (sailsIn) {
client.sendBoatActionMessage(new BoatActionMessage(BoatActionType.SAILS_OUT));
} else {
client.sendBoatActionMessage(new BoatActionMessage(BoatActionType.SAILS_IN));
}
}
}
@Then("^the sails are \"([^\"]*)\"$")
public void the_sails_are(String arg1) throws Throwable {
System.out.println(GameState.getYachts().values());
}
}