The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results forĀ 
Search instead forĀ 
Did you mean:Ā 

Bitbucket Pipelines marked as success even if one test failed

Andreas
January 4, 2020

I have a test project that runs tSQLt tests on a separate service running the MSSQL 2017 server image.

The tests run correctly, and the output is in a correct XML format.

But even though one test failed:
test_detected_and_failed.png

The pipeline is still marked successful:
pipelines_success.png

What am I missing here?

Thanks in advance for the help!

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Philip Hodder
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 6, 2020

Hi,

A Pipeline is marked as success or failed based on the exit code of all the commands set. So if your command has the exit code 0, we will still mark that as successful. Most tools will return a non-zero exit code when a test fails. Perhaps you can configure your tool to have a different exit code.

The test output shown is read straight from the xUnit XML output. It doesn't influence the final result of the pipeline.

Thanks,

Phil

Andreas
January 7, 2020

Hi Phil,

Thanks for the answer! I am now able to have the Pipeline fail when a test fail. And if you do not mind, I have a follow-up question.

Currently my (simplified for the example) steps are:

# Run all tests
sqlcmd -b -Q "EXEC tSQLt.RunAll"
# Generate XML reports
sqlcmd -Q "EXEC tSQLt.XmlResultFormatter" -o test-reports/tsqlt.xml

Because I use the sqlcmd utility with the "-b" option, the first line returns an exit code different than 0.

But then I cannot execute the next steps (generate the reports). Do you have any idea how to solve this?

Regards

Andreas

Andreas
March 20, 2020

As a workaround, I am using the following steps:

# Run all tests without the "_b" option, to not stop on errors
sqlcmd -Q "EXEC tSQLt.RunAll"

# Generate XML reports
sqlcmd -Q "EXEC tSQLt.XmlResultFormatter" -o test-reports/tsqlt.xml

# And finally, run all tests again, this time with the "-b" option, to make Pipelines fail if there is any error
sqlcmd -b -Q "EXEC tSQLt.RunAll
TAGS
AUG Leaders

Atlassian Community Events