当前位置: 首页>>代码示例>>Java>>正文


Java After类代码示例

本文整理汇总了Java中cucumber.api.java.After的典型用法代码示例。如果您正苦于以下问题:Java After类的具体用法?Java After怎么用?Java After使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


After类属于cucumber.api.java包,在下文中一共展示了After类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: embedScreenshot

import cucumber.api.java.After; //导入依赖的package包/类
@After
public void embedScreenshot(Scenario scenario) {
  try {
    if (!scenario.isFailed()) {
      // Take a screenshot only in the failure case
      return;
    }

    String webDriverType = System.getProperty("WebDriverType");
    if (!webDriverType.equals("HtmlUnit")) {
      // HtmlUnit does not support screenshots
      byte[] screenshot = getScreenshotAs(OutputType.BYTES);
      scenario.embed(screenshot, "image/png");
    }
  } catch (WebDriverException somePlatformsDontSupportScreenshots) {
    scenario.write(somePlatformsDontSupportScreenshots.getMessage());
  }
}
 
开发者ID:robinsteel,项目名称:Sqawsh,代码行数:19,代码来源:SharedDriver.java

示例2: teardown

import cucumber.api.java.After; //导入依赖的package包/类
/**
 * Runs after every Cucumber test scenario.
 * @param scenario      The test scenario that has run
 */
@After
public void teardown(Scenario scenario) {
    logger.debug("After cucumber scenario: ********** {} **********", scenario.getName());

    // add to the test report
    outputDataUse(scenario);
    outputFinalScreenshot(scenario);
    outputFinalHtml(scenario);

    // log the current user out, if they are logged in
    if (driverWrapper.hasLink("Sign out")) {
        logger.debug("Logging the current user out...");
        driverWrapper.clickLink("Sign out");
    }

    // test cleanup (note: this will clear permanent cookies but not HTTP/Session cookies)
    driverWrapper.reset();
}
 
开发者ID:dvsa,项目名称:mot-automated-testsuite,代码行数:23,代码来源:LifecycleHooks.java

示例3: afterTest

import cucumber.api.java.After; //导入依赖的package包/类
/**
 * <p>
 * Takes screen-shot if the scenario fails
 * </p>
 *
 * @param scenario will be the individual scenario's within the Feature files
 * @throws InterruptedException Exception thrown if there is an interuption within the JVM
 */
@After()
public void afterTest(Scenario scenario) throws InterruptedException {
    LOG.info("Taking screenshot IF Test Failed");
    System.out.println("Taking screenshot IF Test Failed (sysOut)");
    if (scenario.isFailed()) {
        try {
            System.out.println("Scenario FAILED... screen shot taken");
            scenario.write(getDriver().getCurrentUrl());
            byte[] screenShot = ((TakesScreenshot) getDriver()).getScreenshotAs(OutputType.BYTES);
            scenario.embed(screenShot, "image/png");
        } catch (WebDriverException e) {
            LOG.error(e.getMessage());
        }
    }
}
 
开发者ID:usman-h,项目名称:Habanero,代码行数:24,代码来源:ScreenShotHook.java

示例4: tearDown

import cucumber.api.java.After; //导入依赖的package包/类
@After
public void tearDown(Scenario scenario) {
    if (scenario.isFailed()) {
        try {
            logger.info("Test failed, taking screenshot");
            byte[] screenshot = ((TakesScreenshot) new Augmenter().augment(getAppiumDriver()))
                    .getScreenshotAs(OutputType.BYTES);
            scenario.embed(screenshot, "image/png");
        }
        catch (WebDriverException wde) {
            System.err.println(wde.getMessage());
        }
        catch (ClassCastException cce) {
            cce.printStackTrace();
        }
    }
    application.tearDown();
}
 
开发者ID:HotwireDotCom,项目名称:bdd-test-automation-for-mobile,代码行数:19,代码来源:SetupTeardownSteps.java

示例5: afterScenario

import cucumber.api.java.After; //导入依赖的package包/类
@After
public void afterScenario( Scenario scenario ) throws Exception
{
    try
    {
        attachLog();

        if( scenario.isFailed() )
        {
            try
            {
                scenario.write( "Current Page URL is " + getDriver().getCurrentUrl() );
                byte[] screenshot;
                try
                {
                    screenshot = ( ( TakesScreenshot ) getDriver() ).getScreenshotAs( OutputType.BYTES );
                } catch( ClassCastException weNeedToAugmentOurDriverObject )
                {
                    screenshot = ( ( TakesScreenshot ) new Augmenter().augment( getDriver() ) ).getScreenshotAs( OutputType.BYTES );
                }
                String relativeScrnShotPath = takeScreenshot().substring(takeScreenshot().indexOf("screenshots"));
                Reporter.addScreenCaptureFromPath(relativeScrnShotPath, getDriver().getCurrentUrl());
            } catch( WebDriverException somePlatformsDontSupportScreenshots )
            {
                System.err.println( somePlatformsDontSupportScreenshots.getMessage() );
            }
        }
    } finally
    {
        closeDriverObjects();
    }
}
 
开发者ID:hemano,项目名称:cucumber-framework-java,代码行数:33,代码来源:StartingSteps.java

示例6: discardEditedDocument

import cucumber.api.java.After; //导入依赖的package包/类
/**
 * <p>
 * Closes the current publication discarding current changes.
 * </p><p>
 * Only applicable to scenarios that leave the document in editable state; implemented as an {@linkplain After}
 * hook rather than a step because this is really a test cleanup/tear-down activity that doesn't warrant expressing
 * explicitly as a scenario step.
 * </p><p>
 * To ensure that this method gets called at the end of your scenario, tag the scenario with
 * {@code @DiscardAfter}.
 * </p>
 */
@After(value = "@DiscardAfter", order = 500)
public void discardEditedDocument() throws Throwable {
    Publication currentPublication = testDataRepo.getCurrentPublication();
    if (currentPublication != null) {
        final String currentPublicationName = currentPublication.getName();
        log.debug("Discarding and closing current publication: {}.", currentPublicationName);
        contentPage.discardUnsavedChanges(currentPublicationName);
    }

    Dataset dataset = testDataRepo.getDataset();
    if (dataset != null) {
        String datasetName = dataset.getName();
        log.debug("Discarding and closing current dataset: {}.", datasetName);
        contentPage.discardUnsavedChanges(datasetName);
    }

    PublicationSeries series = testDataRepo.getPublicationSeries();
    if (series != null) {
        final String currentSeriesName = series.getName();
        log.debug("Discarding and closing current series: {}.", currentSeriesName);
        contentPage.discardUnsavedChanges(currentSeriesName);
    }
}
 
开发者ID:NHS-digital-website,项目名称:hippo,代码行数:36,代码来源:TestDataSteps.java

示例7: afterScenario

import cucumber.api.java.After; //导入依赖的package包/类
@After
public void afterScenario() throws Exception {
  // Remove any bookings made by the scenario - so next scenario can start
  // with a 'clean slate'.
  assertTrue("Expect bookings page to be loaded before calling this method",
      courtAndTimeSlotChooserPage.isLoaded());

  BookingSet bookingsThatFailedToCancel = new BookingSet();
  bookingsPotentiallyMadeDuringScenario.stream().forEach(
      b -> {
        try {
          courtAndTimeSlotChooserPage.cancelCourt(b.getCourt(), b.getTime(), b.getDate(),
              b.getName(), "pAssw0rd", true);
        } catch (Exception e) {
          e.printStackTrace();
          // Note error but continue - we'll fail later
          bookingsThatFailedToCancel.add(b);
        }
      });
  if (!bookingsThatFailedToCancel.isEmpty()) {
    fail("Error cancelling bookings in scenario teardown");
  }
}
 
开发者ID:robinsteel,项目名称:Sqawsh,代码行数:24,代码来源:Hooks.java

示例8: after

import cucumber.api.java.After; //导入依赖的package包/类
@After
public void after() {
    takeScreenshotOnFail();
    if (mActivity != null) { // Close activity after each test scenario
        if (!mActivity.isFinishing()) {
            mActivity.finish();
        }
        try {
            if (mDoneSignal != null) {
                if (!mDoneSignal.await(10, TimeUnit.SECONDS)) {
                    if (Log.D) Log.d(TAG, "FirstRunWizard activity didn't finish properly in the given time");
                }
            }
        } catch (final InterruptedException ex) {
            if (Log.D) Log.d(TAG, "FirstRunWizard activity didn't finish properly in the given time");
        }
    }
    mDoneSignal = null;
}
 
开发者ID:sebaslogen,项目名称:espresso-cucumber,代码行数:20,代码来源:FirstRunWizardTestSteps.java

示例9: afterScenario

import cucumber.api.java.After; //导入依赖的package包/类
@After
public void afterScenario() {
	// free allocated resources
	// In case environment is not deleted we force its deletion
	if (environmentDetailsPage != null) {
		if (!environmentDetailsPage.isDeleted()) {
			logger.debug("Deleting environment");
			environmentDetailsPage.delete();
			thenTheEnvironmentShouldBeDeletedWithin(10); // minutes
		} else {
			logger.debug("environment is already deleted: no need to force its deletion");
		}

	} else {
		logger.debug("environmentPage is null: unable to delete environment");
	}
	environmentDetailsPage = null;
}
 
开发者ID:orange-cloudfoundry,项目名称:elpaaso-core,代码行数:19,代码来源:EnvironmentStoriesSteps.java

示例10: afterClass

import cucumber.api.java.After; //导入依赖的package包/类
@After
public void afterClass(Scenario scenario) throws InterruptedException, IOException {
    if (scenario.isFailed()) {
        try {
            byte[] screenshot =
                    ((TakesScreenshot) AppiumDriverManager.getDriver())
                            .getScreenshotAs(OutputType.BYTES);
            scenario.embed(screenshot, "image/png");
        } catch (WebDriverException wde) {
            System.err.println(wde.getMessage());
        } catch (ClassCastException cce) {
            cce.printStackTrace();
        }
        System.out.println("Inside After" + Thread.currentThread().getId());
    }
    AppiumDriverManager.getDriver().quit();

}
 
开发者ID:saikrishna321,项目名称:AppiumTestDistribution,代码行数:19,代码来源:Hooks.java

示例11: takeScreenshot

import cucumber.api.java.After; //导入依赖的package包/类
@After
public void takeScreenshot(final Scenario scenario) {

    if (scenario.isFailed() && webDriver instanceof TakesScreenshot) {
        final String scenarioName = scenario.getName();
        takeScreenshot(scenarioName, (TakesScreenshot) webDriver);
    }
}
 
开发者ID:KyleRogers,项目名称:cylus,代码行数:9,代码来源:ScreenshotHook.java

示例12: afterScenario

import cucumber.api.java.After; //导入依赖的package包/类
/**
 * Capture a selenium screenshot when a test fails and add it to the Cucumber generated report
 * if the scenario has accessed selenium in its lifetime
 * @throws InterruptedException 
 */
@After
public void afterScenario(Scenario scenario) throws InterruptedException {
    log.debug("Scenarion finished");
    ScenarioGlobals scenarioGlobals = getCucumberManager().getCurrentScenarioGlobals();
	TestEnvironment testNev = getSeleniumManager().getAssociatedTestEnvironment();
	if (testNev != null && scenarioGlobals != null) {
		boolean scenarioUsedSelenium = testNev.isWebDriverAccessedSince(scenarioGlobals.getScenarioStart());
		if (scenarioUsedSelenium) {
			if (scenario.isFailed()) {
				log.debug("Scenarion failed while using selenium, so capture screenshot");
				TakesScreenshot seleniumDriver = (TakesScreenshot) SenBotContext.getSeleniumDriver();
	byte[] screenshotAs = seleniumDriver.getScreenshotAs(OutputType.BYTES);
	scenario.embed(screenshotAs, "image/png");
			}
		}
	}
    getCucumberManager().stopNewScenario();
}
 
开发者ID:gfk-ba,项目名称:senbot,代码行数:24,代码来源:CucumberReportingExtension.java

示例13: cleanup

import cucumber.api.java.After; //导入依赖的package包/类
@After
public void cleanup() throws SQLException {
    if (pugTSDB != null) {
        try (Statement statement = pugTSDB.getDataSource().getConnection().createStatement()) {
            statement.execute(" DROP ALL OBJECTS DELETE FILES ");
        } finally {
            pugTSDB.close();
        }
    }
}
 
开发者ID:StefaniniInspiring,项目名称:pugtsdb,代码行数:11,代码来源:UpsertionSteps.java

示例14: cleanup

import cucumber.api.java.After; //导入依赖的package包/类
@After
public void cleanup() throws SQLException {
    if (actualPug != null) {
        try (Statement statement = actualPug.getDataSource().getConnection().createStatement()) {
            statement.execute(" DROP ALL OBJECTS DELETE FILES ");
        } finally {
            actualPug.close();
        }
    }
}
 
开发者ID:StefaniniInspiring,项目名称:pugtsdb,代码行数:11,代码来源:PugCreationSteps.java

示例15: after

import cucumber.api.java.After; //导入依赖的package包/类
/**
 * Test method executed after each test method.
 */
@After
public void after() throws Exception {

    // Cleanup the testing bucket
    this.cleanupTestingBucket();

}
 
开发者ID:gomoob,项目名称:java-aws-s3,代码行数:11,代码来源:S3Test.java


注:本文中的cucumber.api.java.After类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。