File tree Expand file tree Collapse file tree
stepup/tests/behat/features/bootstrap Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212use Surfnet \StepupBehat \ValueObject \Identity ;
1313use Surfnet \StepupBehat \ValueObject \SecondFactorToken ;
1414use Surfnet \StepupBehat \ValueObject \InstitutionConfiguration ;
15+ use Behat \Behat \Hook \Scope \AfterStepScope ;
1516
1617class FeatureContext implements Context
1718{
@@ -450,4 +451,27 @@ public function diePrintingContent()
450451 echo $ this ->minkContext ->getSession ()->getPage ()->getContent ();
451452 die;
452453 }
454+
455+ /**
456+ * @AfterStep
457+ */
458+ public function dumpPageContentAfterFailedStep (AfterStepScope $ scope )
459+ {
460+ if ($ scope ->getTestResult ()->getResultCode () === \Behat \Testwork \Tester \Result \TestResult::FAILED ) {
461+ $ session = $ this ->minkContext ->getSession ();
462+ if ($ session ->getDriver () instanceof \Behat \Mink \Driver \GoutteDriver) {
463+ $ content = $ session ->getPage ()->getContent ();
464+ $ url = $ session ->getCurrentUrl ();
465+ $ headers = $ session ->getResponseHeaders ();
466+ fwrite (STDERR , "\nStep failed: \n" );
467+ fwrite (STDERR , "URL: " .$ url ."\n" );
468+ foreach ($ headers as $ header => $ values ) {
469+ foreach ($ values as $ value )
470+ fwrite (STDERR , $ header .": " .$ value ."\n" );
471+ }
472+ fwrite (STDERR , "\n" .$ content ."\n" );
473+
474+ }
475+ }
476+ }
453477}
You can’t perform that action at this time.
0 commit comments