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 Bitbucket Pipelines

What We Learned When We Researched Open Source Vulnerabilities in 7 Popular Coding Languages

...hey are a part of us, shaping how we interact with the world around us. The same holds true for programming languages when we think about how different kinds of vulnerabilities raise their heads in t...

1,051 views 0 3
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