@@ -181,6 +181,7 @@ public function afterStep(AfterStepTested $event)
181
181
$ resultCode = $ event ->getTestResult ()->getResultCode ();
182
182
$ stepText = sprintf ("%s %s " , $ event ->getStep ()->getKeyword (), $ event ->getStep ()->getText ());
183
183
$ valuesTables = [];
184
+ $ screenshotOnFailed = Athena::settings ()->get ('bddScreenshotOnlyOnFailed ' )->orDefaultTo (true );
184
185
185
186
// not the most pretty implementation
186
187
if ($ event ->getStep ()->hasArguments ()) {
@@ -203,10 +204,22 @@ public function afterStep(AfterStepTested $event)
203
204
}
204
205
}
205
206
206
- $ imageFileName = $ this ->takeScreenshot ();
207
- $ httpTransactions = $ this ->getHttpTransactionEvents ();
207
+ if (($ resultCode == TestResult::FAILED ) && ($ screenshotOnFailed == true )){
208
+ $ imageFileName = $ this ->takeScreenshot ();
209
+ $ httpTransactions = $ this ->getHttpTransactionEvents ();
208
210
209
- $ this ->report ->finishStep ($ stepText , $ valuesTables , $ resultCode , $ imageFileName , $ exceptionMessage , $ exceptionTrace , $ exceptionType , $ httpTransactions );
211
+ $ this ->report ->finishStep ($ stepText , $ valuesTables , $ resultCode , $ imageFileName , $ exceptionMessage , $ exceptionTrace , $ exceptionType , $ httpTransactions );
212
+ } elseif ($ screenshotOnFailed == false ) {
213
+ $ imageFileName = $ this ->takeScreenshot ();
214
+ $ httpTransactions = $ this ->getHttpTransactionEvents ();
215
+
216
+ $ this ->report ->finishStep ($ stepText , $ valuesTables , $ resultCode , $ imageFileName , $ exceptionMessage , $ exceptionTrace , $ exceptionType , $ httpTransactions );
217
+ } elseif (($ resultCode == TestResult::PASSED ) && ($ screenshotOnFailed == true )) {
218
+ $ imageFileName = null ;
219
+ $ httpTransactions = null ;
220
+
221
+ $ this ->report ->finishStep ($ stepText , $ valuesTables , $ resultCode , $ imageFileName , $ exceptionMessage , $ exceptionTrace , $ exceptionType , $ httpTransactions );
222
+ }
210
223
}
211
224
212
225
/**
0 commit comments