How to use getTestOutcomes method of net.thucydides.junit.listeners.JUnitStepListener class

Best Serenity JUnit code snippet using net.thucydides.junit.listeners.JUnitStepListener.getTestOutcomes

Source:SerenityRunner.java Github

copy

Full Screen

...229 StepEventBus.getEventBus().dropAllListeners();230 }231 }232 private Optional<TestOutcome> latestOutcome() {233 if (StepEventBus.getEventBus().getBaseStepListener().getTestOutcomes().isEmpty()) {234 return Optional.empty();235 }236 return Optional.of(StepEventBus.getEventBus().getBaseStepListener().getTestOutcomes().get(0));237 }238 private void fireNotificationsBasedOnTestResultsTo(RunNotifier notifier) {239 if (!latestOutcome().isPresent()) {240 return;241 }242 }243 private void notifyTestSuiteFinished() {244 try {245 if (dataDrivenTest()) {246 StepEventBus.getEventBus().exampleFinished();247 } else {248 StepEventBus.getEventBus().testSuiteFinished();249 }250 } catch (Throwable listenerException) {251 // We report and ignore listener exceptions so as not to mess up the rest of the test mechanics.252 logger.error("Test event bus error: " + listenerException.getMessage(), listenerException);253 }254 }255 private boolean dataDrivenTest() {256 return this instanceof TestClassRunnerForParameters;257 }258 private void dropListeners(final RunNotifier notifier) {259 JUnitStepListener listener = getStepListener();260 notifier.removeListener(listener);261 getStepListener().dropListeners();262 }263 protected void generateReports() {264 generateReportsFor(getTestOutcomes());265 }266 private boolean skipThisTest() {267 return testNotInCurrentBatch();268 }269 private boolean testNotInCurrentBatch() {270 return (batchManager != null) && (!batchManager.shouldExecuteThisTest(getDescription().testCount()));271 }272 /**273 * The Step Listener observes and records what happens during the execution of the test.274 * Once the test is over, the Step Listener can provide the acceptance test outcome in the275 * form of an TestOutcome object.276 * @return the current step listener277 */278 protected JUnitStepListener getStepListener() {279 if (stepListener == null) {280 buildAndConfigureListeners();281 }282 return stepListener;283 }284 protected void setStepListener(JUnitStepListener stepListener) {285 this.stepListener = stepListener;286 }287 private void buildAndConfigureListeners() {288 initStepEventBus();289 if (webtestsAreSupported()) {290 ThucydidesWebDriverSupport.initialize(requestedDriver);291 WebDriver driver = ThucydidesWebDriverSupport.getWebdriverManager().getWebdriver();292 initPagesObjectUsing(driver);293 setStepListener(initListenersUsing(getPages()));294 initStepFactoryUsing(getPages());295 } else {296 setStepListener(initListeners());297 initStepFactory();298 }299 }300 private RunNotifier initializeRunNotifier(RunNotifier notifier) {301 notifier.addListener(getStepListener());302 return notifier;303 }304 private int maxRetries() {305 return TEST_RETRY_COUNT.integerFrom(configuration.getEnvironmentVariables(), 0);306 }307 protected void initStepEventBus() {308 StepEventBus.getEventBus().clear();309 }310 private void initPagesObjectUsing(final WebDriver driver) {311 pages = new Pages(driver, getConfiguration());312 dependencyInjector = new PageObjectDependencyInjector(pages);313 }314 protected JUnitStepListener initListenersUsing(final Pages pageFactory) {315 return JUnitStepListener.withOutputDirectory(getConfiguration().getOutputDirectory())316 .and().withPageFactory(pageFactory)317 .and().withTestClass(getTestClass().getJavaClass())318 .and().build();319 }320 protected JUnitStepListener initListeners() {321 return JUnitStepListener.withOutputDirectory(getConfiguration().getOutputDirectory())322 .and().withTestClass(getTestClass().getJavaClass())323 .and().build();324 }325 private boolean webtestsAreSupported() {326 return TestCaseAnnotations.supportsWebTests(this.getTestClass().getJavaClass());327 }328 private void initStepFactoryUsing(final Pages pagesObject) {329 stepFactory = StepFactory.getFactory().usingPages(pagesObject);330 }331 private void initStepFactory() {332 stepFactory = StepFactory.getFactory();333 }334 private ReportService getReportService() {335 if (reportService == null) {336 reportService = new ReportService(getOutputDirectory(), getDefaultReporters());337 }338 return reportService;339 }340 /**341 * A test runner can generate reports via Reporter instances that subscribe342 * to the test runner. The test runner tells the reporter what directory to343 * place the reports in. Then, at the end of the test, the test runner344 * notifies these reporters of the test outcomes. The reporter's job is to345 * process each test run outcome and do whatever is appropriate.346 *347 * @param testOutcomeResults the test results from the previous test run.348 */349 private void generateReportsFor(final List<TestOutcome> testOutcomeResults) {350 getReportService().generateReportsFor(testOutcomeResults);351 getReportService().generateConfigurationsReport();352 }353 @Override354 protected void runChild(FrameworkMethod method, RunNotifier notifier) {355 TestMethodConfiguration theMethod = TestMethodConfiguration.forMethod(method);356 clearMetadataIfRequired();357 resetStepLibrariesIfRequired();358 if(!failureRerunner.hasToRunTest(method.getDeclaringClass().getCanonicalName(),method.getMethod().getName()))359 {360 return;361 }362 if (shouldSkipTest(method)) {363 return;364 }365 if (theMethod.isManual()) {366 markAsManual(method).accept(notifier);367 return;368 } else if (theMethod.isPending()) {369 markAsPending(method);370 notifier.fireTestIgnored(describeChild(method));371 return;372 } else {373 processTestMethodAnnotationsFor(method);374 }375 initializeTestSession();376 prepareBrowserForTest();377 additionalBrowserCleanup();378 performRunChild(method, notifier);379 if (failureDetectingStepListener.lastTestFailed() && maxRetries() > 0) {380 retryAtMost(maxRetries(), new RerunSerenityTest(method, notifier));381 }382 }383 private void retryAtMost(int remainingTries,384 RerunTest rerunTest) {385 if (remainingTries <= 0) { return; }386 logger.info(rerunTest.toString() + ": attempt " + (maxRetries() - remainingTries));387 StepEventBus.getEventBus().cancelPreviousTest();388 rerunTest.perform();389 if (failureDetectingStepListener.lastTestFailed()) {390 retryAtMost(remainingTries - 1, rerunTest);391 } else {392 StepEventBus.getEventBus().lastTestPassedAfterRetries(remainingTries,393 failureDetectingStepListener.getFailureMessages(),failureDetectingStepListener.getTestFailureCause());394 }395 }396 private void performRunChild(FrameworkMethod method, RunNotifier notifier) {397 super.runChild(method, notifier);398 }399 interface RerunTest {400 void perform();401 }402 class RerunSerenityTest implements RerunTest {403 private final FrameworkMethod method;404 private final RunNotifier notifier;405 RerunSerenityTest(FrameworkMethod method, RunNotifier notifier) {406 this.method = method;407 this.notifier = notifier;408 }409 @Override410 public void perform() {411 performRunChild(method, notifier);412 }413 @Override414 public String toString() {415 return "Retrying " + method.getDeclaringClass() + " " + method.getMethod().getName();416 }417 }418 private void clearMetadataIfRequired() {419 if (theTest.shouldClearMetadata()) {420 Serenity.getCurrentSession().clearMetaData();421 }422 }423 private void resetStepLibrariesIfRequired() {424 if (theTest.shouldResetStepLibraries()) {425 stepFactory.reset();426 }427 }428 protected void additionalBrowserCleanup() {429 // Template method. Override this to do additional cleanup e.g. killing IE processes.430 }431 private boolean shouldSkipTest(FrameworkMethod method) {432 return !tagScanner.shouldRunMethod(getTestClass().getJavaClass(), method.getName());433 }434 private void markAsPending(FrameworkMethod method) {435 testStarted(method);436 StepEventBus.getEventBus().testPending();437 StepEventBus.getEventBus().testFinished();438 }439 private Consumer<RunNotifier> markAsManual(FrameworkMethod method) {440 TestMethodConfiguration theMethod = TestMethodConfiguration.forMethod(method);441 testStarted(method);442 StepEventBus.getEventBus().testIsManual();443 StepEventBus.getEventBus().getBaseStepListener().latestTestOutcome().ifPresent(444 outcome -> outcome.setResult(theMethod.getManualResult())445 );446 switch(theMethod.getManualResult()) {447 case SUCCESS:448 StepEventBus.getEventBus().testFinished();449 return (notifier -> notifier.fireTestFinished(Description.EMPTY));450 case FAILURE:451 Throwable failure = new ManualTestMarkedAsFailure(theMethod.getManualResultReason());452 StepEventBus.getEventBus().testFailed(failure);453 return (notifier -> notifier.fireTestFailure(454 new Failure(Description.createTestDescription(method.getDeclaringClass(), method.getName()),failure)));455 case ERROR:456 case COMPROMISED:457 case UNSUCCESSFUL:458 Throwable error = new ManualTestMarkedAsError(theMethod.getManualResultReason());459 StepEventBus.getEventBus().testFailed(error);460 return (notifier -> notifier.fireTestFailure(461 new Failure(Description.createTestDescription(method.getDeclaringClass(), method.getName()),error)));462 case IGNORED:463 StepEventBus.getEventBus().testIgnored();464 return (notifier -> notifier.fireTestIgnored(Description.createTestDescription(method.getDeclaringClass(), method.getName())));465 case SKIPPED:466 StepEventBus.getEventBus().testSkipped();467 return (notifier -> notifier.fireTestIgnored(Description.createTestDescription(method.getDeclaringClass(), method.getName())));468 default:469 StepEventBus.getEventBus().testPending();470 return (notifier -> notifier.fireTestIgnored(Description.createTestDescription(method.getDeclaringClass(), method.getName())));471 }472 }473 private void testStarted(FrameworkMethod method) {474 getStepListener().testStarted(Description.createTestDescription(method.getMethod().getDeclaringClass(), testName(method)));475 }476 /**477 * Process any Serenity annotations in the test class.478 * Ignored tests will just be skipped by JUnit - we need to ensure479 * that they are included in the Serenity reports480 * If a test method is pending, all the steps should be skipped.481 */482 private void processTestMethodAnnotationsFor(FrameworkMethod method) {483 if (isIgnored(method)) {484 testStarted(method);485 StepEventBus.getEventBus().testIgnored();486 StepEventBus.getEventBus().testFinished();487 }488 }489 protected void prepareBrowserForTest() {490 if (theTest.shouldClearTheBrowserSession()) {491 WebdriverProxyFactory.clearBrowserSession(getDriver());492 }493 }494 /**495 * Running a unit test, which represents a test scenario.496 */497 @Override498 protected Statement methodInvoker(final FrameworkMethod method, final Object test) {499 if (webtestsAreSupported()) {500 injectDriverInto(test);501 initPagesObjectUsing(driverFor(method));502 injectAnnotatedPagesObjectInto(test);503 initStepFactoryUsing(getPages());504 }505 injectScenarioStepsInto(test);506 injectEnvironmentVariablesInto(test);507 useStepFactoryForDataDrivenSteps();508 Statement baseStatement = super.methodInvoker(method, test);509 return new SerenityStatement(baseStatement, stepListener.getBaseStepListener());510 }511 private void useStepFactoryForDataDrivenSteps() {512 StepData.setDefaultStepFactory(stepFactory);513 }514 /**515 * Instantiate the @Managed-annotated WebDriver instance with current WebDriver.516 * @param testCase A Serenity-annotated test class517 */518 protected void injectDriverInto(final Object testCase) {519 TestCaseAnnotations.forTestCase(testCase).injectDrivers(ThucydidesWebDriverSupport.getDriver(),520 ThucydidesWebDriverSupport.getWebdriverManager());521 dependencyInjector.injectDependenciesInto(testCase);522 }523 protected WebDriver driverFor(final FrameworkMethod method) {524 if (TestMethodAnnotations.forTest(method).isDriverSpecified()) {525 String testSpecificDriver = TestMethodAnnotations.forTest(method).specifiedDriver();526 return getDriver(testSpecificDriver);527 } else {528 return getDriver();529 }530 }531 /**532 * Instantiates the @ManagedPages-annotated Pages instance using current WebDriver.533 * @param testCase A Serenity-annotated test class534 */535 protected void injectScenarioStepsInto(final Object testCase) {536 StepAnnotations.injector().injectScenarioStepsInto(testCase, stepFactory);537 }538 /**539 * Instantiates the @ManagedPages-annotated Pages instance using current WebDriver.540 * @param testCase A Serenity-annotated test class541 */542 protected void injectAnnotatedPagesObjectInto(final Object testCase) {543 StepAnnotations.injector().injectAnnotatedPagesObjectInto(testCase, pages);544 }545 protected void injectEnvironmentVariablesInto(final Object testCase) {546 EnvironmentDependencyInjector environmentDependencyInjector = new EnvironmentDependencyInjector();547 environmentDependencyInjector.injectDependenciesInto(testCase);548 }549 protected WebDriver getDriver() {550 return (isEmpty(requestedDriver)) ? ThucydidesWebDriverSupport.getWebdriverManager().getWebdriver()551 : ThucydidesWebDriverSupport.getWebdriverManager().getWebdriver(requestedDriver);552 }553 protected WebDriver getDriver(final String driver) {554 return (isEmpty(driver)) ? ThucydidesWebDriverSupport.getWebdriverManager().getWebdriver()555 : ThucydidesWebDriverSupport.getWebdriverManager().getWebdriver(driver);556 }557 /**558 * Find the current set of test outcomes produced by the test execution.559 * @return the current list of test outcomes560 */561 public List<TestOutcome> getTestOutcomes() {562 return getStepListener().getTestOutcomes();563 }564 /**565 * @return The default reporters applicable for standard test runs.566 */567 protected Collection<AcceptanceTestReporter> getDefaultReporters() {568 return ReportService.getDefaultReporters();569 }570}...

Full Screen

Full Screen

Source:ThucydidesRunner.java Github

copy

Full Screen

...231 notifier.removeListener(listener);232 getStepListener().dropListeners();233 }234 protected void generateReports() {235 generateReportsFor(getTestOutcomes());236 }237 private boolean skipThisTest() {238 return testNotInCurrentBatch();239 }240 private boolean testNotInCurrentBatch() {241 return (batchManager != null) && (!batchManager.shouldExecuteThisTest(getDescription().testCount()));242 }243 /**244 * The Step Listener observes and records what happens during the execution of the test.245 * Once the test is over, the Step Listener can provide the acceptance test outcome in the246 * form of an TestOutcome object.247 * @return the current step listener248 */249 protected JUnitStepListener getStepListener() {250 if (stepListener == null) {251 buildAndConfigureListeners();252 }253 return stepListener;254 }255 protected void setStepListener(JUnitStepListener stepListener) {256 this.stepListener = stepListener;257 }258 private void buildAndConfigureListeners() {259 initStepEventBus();260 if (webtestsAreSupported()) {261 initPagesObjectUsing(webdriverManager.getWebdriver(requestedDriver));262 setStepListener(initListenersUsing(getPages()));263 initStepFactoryUsing(getPages());264 } else {265 setStepListener(initListeners());266 initStepFactory();267 }268 }269 private RunNotifier initializeRunNotifier(RunNotifier notifier) {270 RunNotifier notifierForSteps = new RunNotifier();271 notifierForSteps.addListener(getStepListener());272 return (shouldRetryTest() ? notifier : new RetryFilteringRunNotifier(notifier, notifierForSteps));273 }274 private boolean shouldRetryTest() {275 return configuration.getEnvironmentVariables().getPropertyAsBoolean(ThucydidesSystemProperty.JUNIT_RETRY_TESTS, false);276 }277 protected void initStepEventBus() {278 StepEventBus.getEventBus().clear();279 }280 private void initPagesObjectUsing(final WebDriver driver) {281 pages = new Pages(driver, getConfiguration());282 dependencyInjector = new PageObjectDependencyInjector(pages);283 }284 protected JUnitStepListener initListenersUsing(final Pages pageFactory) {285 return JUnitStepListener.withOutputDirectory(getConfiguration().getOutputDirectory())286 .and().withPageFactory(pageFactory)287 .and().withTestClass(getTestClass().getJavaClass())288 .and().build();289 }290 protected JUnitStepListener initListeners() {291 return JUnitStepListener.withOutputDirectory(getConfiguration().getOutputDirectory())292 .and().withTestClass(getTestClass().getJavaClass())293 .and().build();294 }295 private boolean webtestsAreSupported() {296 return TestCaseAnnotations.supportsWebTests(this.getTestClass().getJavaClass());297 }298 private void initStepFactoryUsing(final Pages pagesObject) {299 stepFactory = new StepFactory(pagesObject);300 }301 private void initStepFactory() {302 stepFactory = new StepFactory();303 }304 private void closeDrivers() {305 getWebdriverManager().closeAllCurrentDrivers();306 }307 protected WebdriverManager getWebdriverManager() {308 return webdriverManager;309 }310 private ReportService getReportService() {311 if (reportService == null) {312 reportService = new ReportService(getOutputDirectory(), getDefaultReporters());313 }314 return reportService;315 }316 /**317 * A test runner can generate reports via Reporter instances that subscribe318 * to the test runner. The test runner tells the reporter what directory to319 * place the reports in. Then, at the end of the test, the test runner320 * notifies these reporters of the test outcomes. The reporter's job is to321 * process each test run outcome and do whatever is appropriate.322 *323 * @param testOutcomeResults the test results from the previous test run.324 */325 private void generateReportsFor(final List<TestOutcome> testOutcomeResults) {326 getReportService().generateReportsFor(testOutcomeResults);327 }328 @Override329 protected void runChild(FrameworkMethod method, RunNotifier notifier) {330 clearMetadataIfRequired();331 if (shouldSkipTest(method)) {332 return;333 }334 if (isPending(method)) {335 markAsPending(method);336 notifier.fireTestIgnored(describeChild(method));337 return;338 } else {339 processTestMethodAnnotationsFor(method);340 }341 FailureDetectingStepListener failureDetectingStepListener = new FailureDetectingStepListener();342 StepEventBus.getEventBus().registerListener(failureDetectingStepListener);343 int maxRetries = getConfiguration().maxRetries();344 for (int attemptCount = 0; attemptCount <= maxRetries; attemptCount++) {345 if (notifier instanceof RetryFilteringRunNotifier) {346 ((RetryFilteringRunNotifier) notifier).reset();347 }348 if (attemptCount > 0) {349 logger.warn(method.getName() + " failed, making attempt " + (attemptCount + 1) + ". Max retries: " + maxRetries);350 StepEventBus.getEventBus().testRetried();351 }352 initializeTestSession();353 resetBroswerFromTimeToTime();354 additionalBrowserCleanup();355 failureDetectingStepListener.reset();356 super.runChild(method, notifier);357 if (!failureDetectingStepListener.lastTestFailed()) {358 break;359 }360 }361 if (notifier instanceof RetryFilteringRunNotifier) {362 ((RetryFilteringRunNotifier) notifier).flush();363 }364 }365 private void clearMetadataIfRequired() {366 if (!configuration.getEnvironmentVariables().getPropertyAsBoolean(ThucydidesSystemProperty.THUCYDIDES_MAINTAIN_SESSION, false)) {367 Thucydides.getCurrentSession().clearMetaData();368 }369 }370 protected void additionalBrowserCleanup() {371 // Template method. Override this to do additional cleanup e.g. killing IE processes.372 }373 private boolean shouldSkipTest(FrameworkMethod method) {374 return !tagScanner.shouldRunMethod(getTestClass().getJavaClass(), method.getName());375 }376 private void markAsPending(FrameworkMethod method) {377 stepListener.testStarted(Description.createTestDescription(method.getMethod().getDeclaringClass(), testName(method)));378 StepEventBus.getEventBus().testPending();379 StepEventBus.getEventBus().testFinished();380 }381 /**382 * Process any Thucydides annotations in the test class.383 * Ignored tests will just be skipped by JUnit - we need to ensure384 * that they are included in the Thucydides reports385 * If a test method is pending, all the steps should be skipped.386 */387 private void processTestMethodAnnotationsFor(FrameworkMethod method) {388 if (isIgnored(method)) {389 stepListener.testStarted(Description.createTestDescription(method.getMethod().getDeclaringClass(), testName(method)));390 StepEventBus.getEventBus().testIgnored();391 }392 }393 private boolean isPending(FrameworkMethod method) {394 return method.getAnnotation(Pending.class) != null;395 }396 private boolean isIgnored(FrameworkMethod method) {397 return method.getAnnotation(Ignore.class) != null;398 }399 protected boolean restartBrowserBeforeTest() {400 return notAUniqueSession() || dueForPeriodicBrowserReset();401 }402 private boolean dueForPeriodicBrowserReset() {403 return shouldRestartEveryNthTest() && (currentTestNumber() % restartFrequency() == 0);404 }405 private boolean notAUniqueSession() {406 return !isUniqueSession();407 }408 protected int restartFrequency() {409 return getConfiguration().getRestartFrequency();410 }411 protected int currentTestNumber() {412 return testCount.getCurrentTestNumber();413 }414 protected boolean shouldRestartEveryNthTest() {415 return (restartFrequency() > 0);416 }417 protected boolean isUniqueSession() {418 return TestCaseAnnotations.isUniqueSession(getTestClass().getJavaClass());419 }420 protected void resetBroswerFromTimeToTime() {421 if (isAWebTest() && restartBrowserBeforeTest()) {422 WebdriverProxyFactory.resetDriver(getDriver());423 }424 }425 /**426 * Running a unit test, which represents a test scenario.427 */428 @Override429 protected Statement methodInvoker(final FrameworkMethod method, final Object test) {430 if (webtestsAreSupported()) {431 injectDriverInto(test, method);432 initPagesObjectUsing(driverFor(method));433 injectAnnotatedPagesObjectInto(test);434 initStepFactoryUsing(getPages());435 }436 injectScenarioStepsInto(test);437 useStepFactoryForDataDrivenSteps();438 Statement baseStatement = super.methodInvoker(method, test);439 return new ThucydidesStatement(baseStatement, stepListener.getBaseStepListener());440 }441 private void useStepFactoryForDataDrivenSteps() {442 StepData.setDefaultStepFactory(stepFactory);443 }444 /**445 * Instantiate the @Managed-annotated WebDriver instance with current WebDriver.446 * @param testCase A Thucydides-annotated test class447 * @param method the test method448 */449 protected void injectDriverInto(final Object testCase,450 final FrameworkMethod method) {451 TestCaseAnnotations.forTestCase(testCase).injectDriver(driverFor(method));452 dependencyInjector.injectDependenciesInto(testCase);453 }454 protected WebDriver driverFor(final FrameworkMethod method) {455 if (TestMethodAnnotations.forTest(method).isDriverSpecified()) {456 String testSpecificDriver = TestMethodAnnotations.forTest(method).specifiedDriver();457 return getDriver(testSpecificDriver);458 } else {459 return getDriver();460 }461 }462 /**463 * Instantiates the @ManagedPages-annotated Pages instance using current WebDriver.464 * @param testCase A Thucydides-annotated test class465 */466 protected void injectScenarioStepsInto(final Object testCase) {467 StepAnnotations.injectScenarioStepsInto(testCase, stepFactory);468 }469 /**470 * Instantiates the @ManagedPages-annotated Pages instance using current WebDriver.471 * @param testCase A Thucydides-annotated test class472 */473 protected void injectAnnotatedPagesObjectInto(final Object testCase) {474 StepAnnotations.injectAnnotatedPagesObjectInto(testCase, pages);475 }476 protected WebDriver getDriver() {477 return getWebdriverManager().getWebdriver(requestedDriver);478 }479 protected WebDriver getDriver(final String driver) {480 return getWebdriverManager().getWebdriver(driver);481 }482 /**483 * Find the current set of test outcomes produced by the test execution.484 * @return the current list of test outcomes485 */486 public List<TestOutcome> getTestOutcomes() {487 return getStepListener().getTestOutcomes();488 }489 /**490 * @return The default reporters applicable for standard test runs.491 */492 protected Collection<AcceptanceTestReporter> getDefaultReporters() {493 return ReportService.getDefaultReporters();494 }495 public boolean isAWebTest() {496 return TestCaseAnnotations.isWebTest(getTestClass().getJavaClass());497 }498}...

Full Screen

Full Screen

Source:JUnitStepListener.java Github

copy

Full Screen

...92 StepEventBus.getEventBus().testIgnored();93 endTest();94 }95 }96 public List<TestOutcome> getTestOutcomes() {97 return baseStepListener.getTestOutcomes();98 }99 public FailureCause getError() {100 return baseStepListener.getTestFailureCause();101 }102 public boolean hasRecordedFailures() {103 return baseStepListener.aStepHasFailed();104 }105 public void dropListeners() {106 StepEventBus.getEventBus().dropListener(baseStepListener);107 for(StepListener listener : extraListeners) {108 StepEventBus.getEventBus().dropListener(listener);109 }110 }111 private void startTest() {...

Full Screen

Full Screen

Source:TestClassRunnerForParameters.java Github

copy

Full Screen

...79 this.qualifier = qualifier;80 super.useQualifier(qualifier);81 }82 @Override83 public List<TestOutcome> getTestOutcomes() {84 return qualified(super.getTestOutcomes());85 }86 private List<TestOutcome> qualified(List<TestOutcome> testOutcomes) {87 List<TestOutcome> qualifiedOutcomes = Lists.newArrayList();88 for(TestOutcome outcome : testOutcomes) {89 qualifiedOutcomes.add(outcome.withQualifier(qualifier));90 }91 return qualifiedOutcomes;92 }93}...

Full Screen

Full Screen

getTestOutcomes

Using AI Code Generation

copy

Full Screen

1public class JUnitStepListener implements StepListener {2 private final List<TestOutcome> testOutcomes = new ArrayList<TestOutcome>();3 public List<TestOutcome> getTestOutcomes() {4 return testOutcomes;5 }6}7public class JUnitStepListener implements StepListener {8 private final List<TestOutcome> testOutcomes = new ArrayList<TestOutcome>();9 public List<TestOutcome> getTestOutcomes() {10 return testOutcomes;11 }12}13public class JUnitStepListener implements StepListener {14 private final List<TestOutcome> testOutcomes = new ArrayList<TestOutcome>();15 public List<TestOutcome> getTestOutcomes() {16 return testOutcomes;17 }18}19public class JUnitStepListener implements StepListener {20 private final List<TestOutcome> testOutcomes = new ArrayList<TestOutcome>();21 public List<TestOutcome> getTestOutcomes() {22 return testOutcomes;23 }24}25public class JUnitStepListener implements StepListener {26 private final List<TestOutcome> testOutcomes = new ArrayList<TestOutcome>();27 public List<TestOutcome> getTestOutcomes() {28 return testOutcomes;29 }30}31public class JUnitStepListener implements StepListener {32 private final List<TestOutcome> testOutcomes = new ArrayList<TestOutcome>();33 public List<TestOutcome> getTestOutcomes() {34 return testOutcomes;35 }36}37public class JUnitStepListener implements StepListener {38 private final List<TestOutcome> testOutcomes = new ArrayList<TestOutcome>();39 public List<TestOutcome> getTestOutcomes() {40 return testOutcomes;41 }42}

Full Screen

Full Screen

getTestOutcomes

Using AI Code Generation

copy

Full Screen

1import net.thucydides.core.annotations.Step;2import net.thucydides.core.annotations.Steps;3import net.thucydides.core.annotations.Title;4import net.thucydides.core.annotations.WithTag;5import net.thucydides.core.annotations.WithTags;6import net.thucydides.core.steps.ScenarioSteps;7import net.thucydides.junit.listeners.JUnitStepListener;8import net.thucydides.junit.runners.ThucydidesRunner;9import net.thucydides.junit.annotations.Concurrent;10import net.thucydides.junit.annotations.ConcurrentMode;11import net.thucydides.junit.annotations.TestData;12import net.thucydides.junit.annotations.UseTestDataFrom;13import java.util.concurrent.TimeUnit;14import org.junit.Test;15import org.junit.runner.RunWith;16@RunWith(ThucydidesRunner.class)17@Concurrent(threads="1", mode=ConcurrentMode.PER_METHOD)18@UseTestDataFrom("src/test/resources/data.csv")19public class TestRunner {20 public static Object[][] testData() {21 return new Object[][] {22 };23 }24 public MySteps steps;25 private String url;26 private String title;27 private String search;28 @WithTag("test")29 @Title("Test with data from csv file")30 public void test() {31 steps.openUrl(url);32 steps.checkTitle(title);33 steps.search(search);34 steps.checkSearchResults();35 }36 public static class MySteps extends ScenarioSteps {37 public void openUrl(String url) {38 getDriver().get(url);39 }40 public void checkTitle(String title) {41 assertThat(getDriver().getTitle(), containsString(title));42 }43 public void search(String search) {44 getDriver().findElement(By.name("q")).sendKeys(search);45 getDriver().findElement(By.name("q")).sendKeys(Keys.RETURN);46 }47 public void checkSearchResults() {48 assertThat(getDriver().findElement(By.id("resultStats")).getText(), containsString("results"));49 }50 }51}

Full Screen

Full Screen

getTestOutcomes

Using AI Code Generation

copy

Full Screen

1import net.thucydides.core.model.TestOutcome;2import net.thucydides.junit.listeners.JUnitStepListener;3import java.util.List;4public class TestOutcomes {5 public static void main(String[] args) {6 JUnitStepListener listener = new JUnitStepListener();7 List<TestOutcome> testOutcomes = listener.getTestOutcomes();8 for (TestOutcome outcome : testOutcomes) {9 System.out.println(outcome.getTestName());10 }11 }12}

Full Screen

Full Screen

getTestOutcomes

Using AI Code Generation

copy

Full Screen

1public class TestWithListener {2 public void testWithListener() {3 System.out.println("Test with listener");4 assertTrue(true);5 }6}7public class TestWithListener2 {8 public void testWithListener2() {9 System.out.println("Test with listener2");10 assertTrue(true);11 }12}13public class TestWithListener3 {14 public void testWithListener3() {15 System.out.println("Test with listener3");16 assertTrue(true);17 }18}19public class TestWithListener4 {20 public void testWithListener4() {21 System.out.println("Test with listener4");22 assertTrue(true);23 }24}25public class TestWithListener5 {26 public void testWithListener5() {27 System.out.println("Test with listener5");28 assertTrue(true);29 }30}31package com.automation.testrunners;32import net.serenitybdd.cucumber.CucumberWithSerenity;33import net.thucydides.junit.runners.ThucydidesRunner;34import net.thucydides.junit.listeners.JUnitStepListener;35import org.junit.runner.RunWith;36import cucumber.api.CucumberOptions;37import cucumber.api.junit.Cucumber;38import cucumber.api.testng.AbstractTestNGCucumberTests;39import cucumber.api.testng.CucumberFeatureWrapper;40import cucumber.api.testng.TestNGCucumberRunner;41import cucumber.api.testng.PickleEventWrapper;42import cucumber.api.testng.FeatureWrapper;43import cucumber.api.testng.TestNGCucumberRunner;44import cucumber.api.CucumberOptions;45import cucumber.api.junit.Cucumber;46import cucumber.api.testng.AbstractTestNGCucumberTests;47import cucumber.api.testng.CucumberFeatureWrapper;48import cucumber.api.testng.FeatureWrapper;49import cucumber.api.testng.PickleEventWrapper;50import cucumber.api.testng.TestNGCucumberRunner;51import org.junit.runner.RunWith;52import org.testng.annotations.DataProvider;53import org.testng.annotations.Test;54import org.testng.annotations.BeforeClass;55import org

Full Screen

Full Screen

getTestOutcomes

Using AI Code Generation

copy

Full Screen

1import net.thucydides.junit.listeners.JUnitStepListener;2import net.thucydides.core.model.TestOutcome;3import net.thucydides.core.model.TestOutcomes;4public class SerenityTest {5 public static void main(String[] args) {6 JUnitStepListener listener = new JUnitStepListener(); 7 TestOutcomes testOutcomes = listener.getTestOutcomes();8 for (TestOutcome testOutcome : testOutcomes) {9 System.out.println(testOutcome.getTitle());10 System.out.println(testOutcome.getTestFailureCause().getMessage());11 }12 }13}

Full Screen

Full Screen

getTestOutcomes

Using AI Code Generation

copy

Full Screen

1 def getTestOutcomes() {2 StepEventBus.getEventBus().getBaseStepListener().testListeners.each { listener ->3 if (listener instanceof JUnitStepListener) {4 }5 }6 StepEventBus.getEventBus().getBaseStepListener().stepListeners.each { listener ->7 if (listener instanceof JUnitStepListener) {8 }9 }10 stepListeners.each { listener ->11 listener.getTestOutcomes().each { outcome ->12 }13 }14 testListeners.each { listener ->15 listener.getTestOutcomes().each { outcome ->16 }17 }18 }19}20[ sourcecode ] def testOutcomes = ThucydidesReports . getCurrentTestOutcomes () [ / sourcecode ]21[ sourcecode ] def testOutcomes = ThucydidesReports . getTestOutcomes ( "my test case name" ) [ / sourcecode ]22[ sourcecode ] def testOutcomes = ThucydidesReports . getTestOutcomes ( "my test class" ) [ /

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Serenity JUnit automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful