Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

After unit tests fail, run a step / add a process to teardown

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?

1 answer

1 accepted

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 

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira

Admins, notify your Jira instance of system-wide changes with the new admin announcement banner

Hi All! We’re excited to share the launch of an announcement banner that lets Jira site administrators communicate directly to their users across their  Jira Cloud instance.  ...

551 views 15 18
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you