As the title states.
Using phpunit, with selinium, headless chrome.
During unit tests, if any test fails, a screenshot is made of the issue. These are stores in a folder, which I want to upload to S3 bucket (as per existing guides), which would allow to see browser view at the point of test fail.
The issue I have is that teardown runs, after phpunit fails, which skips any further script actions.
I also tried to set the copy part as a second step, which also does not run.
So, is there a way to run steps/script actions prior/during teardown?
Solved.
My mistake was to run the unittest command directly in the pipeline yml
I created a bash script, which runs the unittests, capture the result.
If the result is a fail, I create a 'flag file' (tried to set an environment variable, but that did not work)
The bash script always exits with 0 (no error)
If the 'flag file' exists (in later steps) I can do needed actions
./vendor/phpunit/phpunit/phpunit --fail-on-warning --log-junit ./test-reports/junit.xml -c tests/phpunit.xml.dist --testsuite Admin
set RESULT=$?
if [ $RESULT -ne 0 ]; then
echo $RESULT >>./testdata/testfailed.txt
fi
exit 0
The last step in yml:
- if [ ! -f ${BITBUCKET_CLONE_DIR}/Magium/testdata/testfailed.txt ]; then /bin/true; else /bin/false; fi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.