/** * Created by john on 15/07/2014. */ public class WebEnabledStepInstantiationSteps { @Steps SampleWebSteps sampleSteps; @Given("I have a Cucumber feature file containing a web-enabled Thucydides @Steps field") public void featureFileContainsStepsFields() { } @Then("the web-enabled step fields should be instantiated") public void theStepFieldsShouldBeInstantiated() { assertThat(sampleSteps).isNotNull(); } }
private String getActorAttribute() { if (field.getAnnotation(Steps.class) != null) { return field.getAnnotation(Steps.class).actor(); } if (field.getAnnotation(Shared.class) != null) { return field.getAnnotation(Shared.class).actor(); } return null; }
public boolean isSharedInstance() { return (field.getAnnotation(Shared.class) != null) || field.getAnnotation(Steps.class).shared(); }
public boolean isUniqueInstance() { return (field.getAnnotation(Steps.class) != null) && (field.getAnnotation(Steps.class).uniqueInstance()); }
public class CheckValuesStep { String firstname; String lastname; String expectedFirstname; String expectedLastname; @Steps SomeNormalSteps normalSteps; @Step public void checkValues() { normalSteps.processFirstName(firstname); normalSteps.processSecondName(lastname); normalSteps.checkResults(expectedFirstname, expectedLastname); } }
public class WorkplaceLeave implements Task { @Steps OpenAuthenticatorApp openAuthenticatorApp; @Override public <T extends Actor> void performAs(T actor) { User user = (User) actor; SignInUser signInUser = SignInUser.GetSignInUserByFederationProvider(user.getFederationProvider()); actor.attemptsTo( openAuthenticatorApp, Click.on(Main.MENU_BUTTON), Click.on(Main.EDIT_ACCOUNTS_MENU_BUTTON), Click.on(EditAccounts.LIST_ROW_DELETE), Click.on(RemoveAccountDialog.REMOVE_BUTTON) ); } }
public class SomeNonWebDataDrivenSteps { @Steps CheckValuesStep checkValueSteps; String dataSource; @Given("^the data in (.*)$") public void givenTheNamesIn(String dataSource) { this.dataSource = dataSource; } @When("^we enter this data$") public void whenWeEnterThisData() {} @Then("^the values should be correct$") public void thenTheValuesShouldBeCorrect() throws IOException { withTestDataFrom(dataSource).run(checkValueSteps).checkValues(); } }
/** * Created by john on 15/07/2014. */ public class IllegalStepInstantiationSteps { @Steps SampleSteps sampleSteps; public IllegalStepInstantiationSteps(SampleSteps sampleSteps) { this.sampleSteps = sampleSteps; } @Given("I have a step library without a default constructor") public void featureFileContainsStepsFields() { } @Then("the tests should fail with an exception") public void thePageObjectsShouldBeInstantiated() { assertThat(sampleSteps.pageObject).isNotNull(); } }
/** * Created by john on 15/07/2014. */ public class StepInstantiationSteps { @Steps SampleSteps sampleSteps; @Given("I have a Cucumber feature file containing Thucydides @Steps fields") public void featureFileContainsStepsFields() { } @Then("the step fields should be instantiated") public void theStepFieldsShouldBeInstantiated() { assertThat(sampleSteps).isNotNull(); } @Then("the nested pages objects should be instantiated") public void thePageObjectsShouldBeInstantiated() { assertThat(sampleSteps.pageObject).isNotNull(); } }
public class WorkplaceJoin implements Task { @Steps OpenAuthenticatorApp openAuthenticatorApp; @Override public <T extends Actor> void performAs(T actor) { User user = (User) actor; SignInUser signInUser = SignInUser.GetSignInUserByFederationProvider(user.getFederationProvider()); actor.attemptsTo( openAuthenticatorApp, Click.on(Main.MENU_BUTTON), Click.on(Main.SETTINGS_MENU_BUTTON), Click.on(Settings.MANAGE_DEVICE_REGISTRATION_BUTTON), //Need to figure out how to deal with new installation where permission to read contacts is required.... better to grant ahead of time i think. Click.on(ManageDeviceRegistration.ORGANIZATIONAL_EMAIL_TEXTBOX), Enter.theValue(user.getCredential().userName).into(ManageDeviceRegistration.ORGANIZATIONAL_EMAIL_TEXTBOX), Click.on(ManageDeviceRegistration.REGISTER_BUTTON), signInUser ); } }
public class ExpireAccessToken implements Task { @Steps CloseKeyboard closeKeyboard; private String clientId;
private TokenCacheItemReadResult tokenCacheItem = new TokenCacheItemReadResult(); @Steps CloseKeyboard closeKeyboard;
@Steps CuriousSurfer connor;
public class AcquireToken implements Task { @Steps CloseKeyboard closeKeyboard;
private boolean withBroker = false; @Steps CloseKeyboard closeKeyboard;
private int billedPrice; @Steps WidgetSteps widgetSteps;
@RunWith(SerenityRunner.class) public class AddAPetToThePetStoreTest { @Steps PetStoreSteps petStore;