io.cucumber.core.api.Scenario Java Examples
The following examples show how to use
io.cucumber.core.api.Scenario.
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: SetupAndTeardownSteps.java From realworld-serverless-application with Apache License 2.0 | 6 votes |
@After public void afterScenario(Scenario s) { TestEnv.getApplications().forEach(app -> tryDeleteApplication(app.getApplicationId())); try { cognitoUserManager.cleanupCognitoUser(); } catch (Throwable t) { log.warn(String.format("Failed to clean up cognito user %s", TestEnv.getUsername()), t); } Instant endedAt = Instant.now(); long durationMillis = Duration.between(TestEnv.getScenarioStartedAt(), endedAt).toMillis(); if (s.isFailed()) { log.info("Failed scenario \"{}\" at {} (Duration: {} ms)", s.getName(), endedAt, durationMillis); log.info("TestData: {}", TestEnv.getTestData().toString()); } else { log.info("Completed scenario \"{}\" at {} (Duration: {} ms)", s.getName(), endedAt, durationMillis); } tryEmptyTestBuckets(); }
Example #2
Source File: SetupAndTeardownSteps.java From realworld-serverless-application with Apache License 2.0 | 6 votes |
@After public void afterScenario(Scenario s) { TestEnv.getApplications().forEach(app -> tryDeleteApplication(app.getApplicationId())); try { cognitoUserManager.cleanupCognitoUser(); } catch (Throwable t) { log.warn(String.format("Failed to clean up cognito user %s", TestEnv.getUsername()), t); } Instant endedAt = Instant.now(); long durationMillis = Duration.between(TestEnv.getScenarioStartedAt(), endedAt).toMillis(); if (s.isFailed()) { log.info("Failed scenario \"{}\" at {} (Duration: {} ms)", s.getName(), endedAt, durationMillis); log.info("TestData: {}", TestEnv.getTestData().toString()); } else { log.info("Completed scenario \"{}\" at {} (Duration: {} ms)", s.getName(), endedAt, durationMillis); } }
Example #3
Source File: CucumberHooks.java From NoraUi with GNU Affero General Public License v3.0 | 6 votes |
private static void printProgressBuild(Scenario scenario) { int remainingTime = getRemainingTime(); StringBuilder star = new StringBuilder(); StringBuilder postStar = new StringBuilder(); int width = scenario.getSourceTagNames().toString().length() + String.valueOf(Context.getCurrentScenarioData()).length() + String.valueOf(Context.getDataInputProvider().getNbGherkinExample()).length() + String.valueOf(Context.getNbFailure()).length() + String.valueOf(Context.getNbWarning()).length() + String.valueOf(remainingTime).length(); String message = Messages.getMessage(PROGRESS_MESSAGE); for (int i = 0; i < message.length() - 12 + width; i++) { star.append("*"); } postStar.append("*"); for (int i = 0; i < message.length() - 14 + width; i++) { postStar.append(" "); } postStar.append("*"); log.info("{}", star); log.info("{}", postStar); log.info(message, scenario.getSourceTagNames(), Context.getCurrentScenarioData(), Context.getDataInputProvider().getNbGherkinExample(), Context.getNbFailure(), Context.getNbWarning(), remainingTime); log.info("{}", postStar); log.info("{}", star); }
Example #4
Source File: CucumberHooks.java From NoraUi with GNU Affero General Public License v3.0 | 5 votes |
@After() public static void tearDown(Scenario scenario) { log.debug("tearDown {} scenario.", scenario.getName()); log.debug("Context.getCurrentScenarioData()={}", Context.getCurrentScenarioData()); log.debug("ExcelFactory.getNbLines()={}", Context.getDataInputProvider().getNbGherkinExample()); printProgressBuild(scenario); if (Context.getCurrentScenarioData() >= Context.getDataInputProvider().getNbGherkinExample()) { log.debug("Go to next feature"); Context.goToNextFeature(); } else { log.debug("Data remaining on current feature"); } }
Example #5
Source File: ScreenServiceImpl.java From NoraUi with GNU Affero General Public License v3.0 | 5 votes |
/** * {@inheritDoc} */ @Override public void takeScreenshot(Scenario scenario) { log.debug("takeScreenshot with the scenario named [{}]", scenario.getName()); log.debug("size: {}x{}", Context.getDriver().manage().window().getSize().getWidth(), Context.getDriver().manage().window().getSize().getHeight()); final byte[] screenshot = ((TakesScreenshot) Context.getDriver()).getScreenshotAs(OutputType.BYTES); scenario.embed(screenshot, "image/png"); }
Example #6
Source File: SetupAndTeardownSteps.java From realworld-serverless-application with Apache License 2.0 | 5 votes |
@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 |
@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: SetupAndTeardownSteps.java From realworld-serverless-application with Apache License 2.0 | 5 votes |
@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 #9
Source File: AttachmentSteps.java From allure-java with Apache License 2.0 | 4 votes |
@Before("@attachments") public void setup(Scenario scenario) { this.scenario = scenario; }
Example #10
Source File: Hooks.java From extentreports-cucumber4-adapter with Apache License 2.0 | 4 votes |
@After public void after(Scenario scenario) throws IOException { scenario.embed(extractBytes("src/test/resources/logo.png"), "image/png"); }
Example #11
Source File: RpnCalculatorSteps.java From extentreports-cucumber4-adapter with Apache License 2.0 | 4 votes |
@After public void after(Scenario scenario) { // scenario.write("HELLLLOO"); }
Example #12
Source File: RpnCalculatorSteps.java From extentreports-cucumber4-adapter with Apache License 2.0 | 4 votes |
@Before("not @foo") public void before(Scenario scenario) { scenario.write("Runs before scenarios *not* tagged with @foo"); }
Example #13
Source File: Context.java From NoraUi with GNU Affero General Public License v3.0 | 4 votes |
public static Scenario getCurrentScenario() { return getInstance().currentScenario; }
Example #14
Source File: Context.java From NoraUi with GNU Affero General Public License v3.0 | 4 votes |
public static void setCurrentScenario(final Scenario scenario) { getInstance().currentScenario = scenario; }
Example #15
Source File: BookStoreWithHooksIntegrationHooks.java From tutorials with MIT License | 4 votes |
@Before(order=2, value="@Screenshots") public void beforeScenario(Scenario scenario) { takeScreenshot(); }
Example #16
Source File: BookStoreWithHooksIntegrationHooks.java From tutorials with MIT License | 4 votes |
@After public void afterScenario(Scenario scenario) { takeScreenshot(); }
Example #17
Source File: BookStoreWithHooksIntegrationHooks.java From tutorials with MIT License | 4 votes |
@BeforeStep public void beforeStep(Scenario scenario) { takeScreenshot(); }
Example #18
Source File: BookStoreWithHooksIntegrationHooks.java From tutorials with MIT License | 4 votes |
@AfterStep public void afterStep(Scenario scenario) { takeScreenshot(); closeBrowser(); }
Example #19
Source File: Hooks.java From extentreports-cucumber4-adapter with Apache License 2.0 | 2 votes |
@AfterStep public void afterStep(Scenario scenario) { }
Example #20
Source File: ScreenService.java From NoraUi with GNU Affero General Public License v3.0 | 2 votes |
/** * Indicates a driver that can capture a screenshot and store it in different ways. * * @param scenario * is instance of {link cucumber.api.Scenario} */ void takeScreenshot(Scenario scenario);