io.cucumber.java.Before Java Examples

The following examples show how to use io.cucumber.java.Before. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HttpClientSteps.java    From yaks with Apache License 2.0 6 votes vote down vote up
@Before
public void before(Scenario scenario) {
    if (httpClient == null && citrus.getCitrusContext().getReferenceResolver().resolveAll(HttpClient.class).size() == 1L) {
        httpClient = citrus.getCitrusContext().getReferenceResolver().resolve(HttpClient.class);
    } else {
        httpClient = new HttpClientBuilder().build();
    }

    timeout = httpClient.getEndpointConfiguration().getTimeout();

    requestHeaders = new HashMap<>();
    responseHeaders = new HashMap<>();
    requestParams = new HashMap<>();
    requestMessageType = CitrusSettings.DEFAULT_MESSAGE_TYPE;
    responseMessageType = CitrusSettings.DEFAULT_MESSAGE_TYPE;
    requestBody = null;
    responseBody = null;
    bodyValidationExpressions = new HashMap<>();
    outboundDictionary = null;
    inboundDictionary = null;
}
 
Example #2
Source File: HttpServerSteps.java    From yaks with Apache License 2.0 6 votes vote down vote up
@Before
public void before(Scenario scenario) {
    if (httpServer == null && citrus.getCitrusContext().getReferenceResolver().resolveAll(HttpServer.class).size() == 1L) {
        httpServer = citrus.getCitrusContext().getReferenceResolver().resolve(HttpServer.class);
    } else {
        httpServer = new HttpServerBuilder().build();
    }

    requestHeaders = new HashMap<>();
    responseHeaders = new HashMap<>();
    requestParams = new HashMap<>();
    requestMessageType = CitrusSettings.DEFAULT_MESSAGE_TYPE;
    responseMessageType = CitrusSettings.DEFAULT_MESSAGE_TYPE;
    requestBody = null;
    responseBody = null;
    bodyValidationExpressions = new HashMap<>();
}
 
Example #3
Source File: InjectEnvVarsHook.java    From yaks with Apache License 2.0 6 votes vote down vote up
@Before
public void injectEnvVars(Scenario scenario) {
    runner.run(new AbstractTestAction() {
        @Override
        public void doExecute(TestContext context) {
            if (scenario != null) {
                context.setVariable("SCENARIO_ID", scenario.getId());
                context.setVariable("SCENARIO_NAME", scenario.getName());
            }

            Optional<String> namespaceEnv = getEnvSetting(YAKS_NAMESPACE);
            Optional<String> domainEnv = getEnvSetting(CLUSTER_WILDCARD_DOMAIN);

            if (namespaceEnv.isPresent()) {
                context.setVariable(YAKS_NAMESPACE, namespaceEnv.get());

                if (!domainEnv.isPresent()) {
                    context.setVariable(CLUSTER_WILDCARD_DOMAIN, namespaceEnv.get() + DEFAULT_DOMAIN_SUFFIX);
                }
            }

            domainEnv.ifPresent(var -> context.setVariable(CLUSTER_WILDCARD_DOMAIN, var));
        }
    });
}
 
Example #4
Source File: OpenApiSteps.java    From yaks with Apache License 2.0 5 votes vote down vote up
@Before
public void before(Scenario scenario) {
    clientSteps = new HttpClientSteps();
    CitrusAnnotations.injectAll(clientSteps, citrus);
    CitrusAnnotations.injectTestRunner(clientSteps, runner);
    clientSteps.before(scenario);

    operation = null;

    outboundDictionary = new JsonPathMappingDataDictionary();
    inboundDictionary = new JsonPathMappingDataDictionary();
}
 
Example #5
Source File: SetupAndTeardownSteps.java    From realworld-serverless-application with Apache License 2.0 5 votes vote down vote up
@Before
public void beforeScenario(final Scenario s) {
  TestEnv.reset();
  Instant startedAt = Instant.now();
  TestEnv.setScenarioStartedAt(startedAt);
  cognitoUserManager.setupCognitoUser();
  log.info("Starting scenario \"{}\" at {}", s.getName(), startedAt);
}
 
Example #6
Source File: SetupAndTeardownSteps.java    From realworld-serverless-application with Apache License 2.0 5 votes vote down vote up
@Before
public void beforeScenario(final Scenario s) {
  TestEnv.reset();
  Instant startedAt = Instant.now();
  TestEnv.setScenarioStartedAt(startedAt);
  cognitoUserManager.setupCognitoUser();
  log.info("Starting scenario \"{}\" at {}", s.getName(), startedAt);
}
 
Example #7
Source File: CucumberHooks.java    From NoraUi with GNU Affero General Public License v3.0 5 votes vote down vote up
@Before()
public static void setUpScenario(Scenario scenario) throws TechnicalException {
    log.info("setUpScenario [{}] scenario.", scenario.getName());
    if (Context.getCurrentScenarioData() == 0) {
        // Retrieve input data provider (by scenario name) to read
        String scenarioName = System.getProperty("scenario.name") != null ? System.getProperty("scenario.name") : getFeatueName(scenario.getUri());
        log.info("scenarioName: {}.", scenarioName);
        Context.setScenarioName(scenarioName);
        Context.getDataInputProvider().prepare(Context.getScenarioName());
        Context.getDataOutputProvider().prepare(Context.getScenarioName());
        Context.startCurrentScenario();
    }
    // Increment current Excel file line to read
    Context.goToNextData();
    Context.emptyScenarioRegistry();
    Context.saveValue(Constants.IS_CONNECTED_REGISTRY_KEY, String.valueOf(Auth.isConnected()));
    Context.setCurrentScenario(scenario);
    new Result.Success<>(Context.getScenarioName(), Messages.getMessage(SUCCESS_MESSAGE_BY_DEFAULT));
}
 
Example #8
Source File: ApiKeysStepsDefinitions.java    From apm-agent-java with Apache License 2.0 5 votes vote down vote up
@Before
public void init() {
    server.stubFor(get(urlEqualTo("/"))
        .willReturn(aResponse()
            .withTransformers("response-template")
            // just send back auth header (if any) for easy parsing on client side
            .withBody("{{request.headers.Authorization}}")));

    server.start();
}
 
Example #9
Source File: Hooks.java    From justtestlah with Apache License 2.0 5 votes vote down vote up
@Before
public void notifyBefore(Scenario scenario) {
  initHooks();
  for (CucumberHook hook : hooksRegister.getRegisteredHooks()) {
    hook.before(scenario);
  }
}
 
Example #10
Source File: EnrichmentSteps.java    From cukedoctor with Apache License 2.0 4 votes vote down vote up
@Before
public void before() throws IOException {
    metaCuke.setUp();
}
 
Example #11
Source File: RpnCalculatorSteps.java    From pitest-cucumber-plugin with Apache License 2.0 4 votes vote down vote up
@Before("not @foo")
public void before(Scenario scenario) {
    scenario.write("Runs before scenarios *not* tagged with @foo");
}
 
Example #12
Source File: StepDefs.java    From cukedoctor with Apache License 2.0 4 votes vote down vote up
@Before
public void before() throws IOException {
    metaCuke.setUp();
    renderedDocument = null;
}
 
Example #13
Source File: Stepdefs.java    From testcontainers-java with MIT License 4 votes vote down vote up
@Before
public void beforeScenario() {
    container.start();
}
 
Example #14
Source File: CucumberTests.java    From hesperides with GNU General Public License v3.0 4 votes vote down vote up
@Before
public void cleanUp() {
    testContextCleaner.reset();
    testDatabaseCleaner.wipeOutCollections();
}
 
Example #15
Source File: CucumberMongoIntegTests.java    From hesperides with GNU General Public License v3.0 4 votes vote down vote up
@Before
public void cleanUp() {
    testContextCleaner.reset();
    testDatabaseCleaner.wipeOutCollections();
}
 
Example #16
Source File: CucumberActiveDirectoryIntegTests.java    From hesperides with GNU General Public License v3.0 4 votes vote down vote up
@Before
public void cleanUp() {
    testContextCleaner.reset();
    testDatabaseCleaner.wipeOutCollections();
}
 
Example #17
Source File: CucumberContextSteps.java    From neodymium-library with MIT License 4 votes vote down vote up
@Before
public void beforeTest()
{
    // setup browser since we set our selenide defaults only if a browser is involved
    WebDriverUtils.setUp("Chrome_headless");
}
 
Example #18
Source File: HooksStepDefinitions.java    From cucumber with MIT License 4 votes vote down vote up
@Before
public void before() {
  // no-op
}
 
Example #19
Source File: HooksStepDefinitions.java    From cucumber with MIT License 4 votes vote down vote up
@Before("@beforeHook")
public void before2() {
  // no-op
}
 
Example #20
Source File: HooksStepDefinitions.java    From cucumber with MIT License 4 votes vote down vote up
@Before("@failBeforeHook")
public void beforeFailed() throws Exception {
  throw new Exception("BOOM !");
}
 
Example #21
Source File: HookSteps.java    From allure-java with Apache License 2.0 4 votes vote down vote up
@Before("@bf")
public void beforeFailed() {
    throw new AssertionError("This hook should fail");
}
 
Example #22
Source File: BookStoreRunSteps.java    From tutorials with MIT License 4 votes vote down vote up
@Before
public void setUp() {
    store = new BookStore();
    foundBooks = new ArrayList<>();
}
 
Example #23
Source File: BookStoreRunSteps.java    From tutorials with MIT License 4 votes vote down vote up
@Before
public void setUp() {
    store = new BookStore();
    foundBooks = new ArrayList<>();
}
 
Example #24
Source File: BookStoreWithHooksIntegrationHooks.java    From tutorials with MIT License 4 votes vote down vote up
public BookStoreWithHooksIntegrationHooks() {
    Before(1, () -> startBrowser());
}
 
Example #25
Source File: BookStoreWithHooksIntegrationHooks.java    From tutorials with MIT License 4 votes vote down vote up
@Before(order=2, value="@Screenshots")
public void beforeScenario(Scenario scenario) {
    takeScreenshot();
}
 
Example #26
Source File: CalculatorRunSteps.java    From tutorials with MIT License 4 votes vote down vote up
@Before
private void init() {
    total = -999;

}
 
Example #27
Source File: CucumberSupport.java    From neodymium-library with MIT License 4 votes vote down vote up
@Before("@SetUpWithBrowserTag")
public static void setUp(Scenario scenario)
{
    WebDriverUtils.setUpWithBrowserTag(scenario);
}
 
Example #28
Source File: SearchStepDefinitions.java    From serenity-cucumber-starter with Apache License 2.0 4 votes vote down vote up
@Before
public void setTheStage() {
    OnStage.setTheStage(new OnlineCast());
}
 
Example #29
Source File: AttachmentSteps.java    From allure-java with Apache License 2.0 4 votes vote down vote up
@Before("@attachments")
public void setup(Scenario scenario)
{
    this.scenario = scenario;
}
 
Example #30
Source File: HookSteps.java    From allure-java with Apache License 2.0 4 votes vote down vote up
@Before("@bp")
public void beforePassed() {
}