Serhiy Serhiy - 1 year ago 93
Python Question

py.test in Jenkins: No tests found in slack. Where I'm wrong?

I keep receiving an error when run Build. py.tests in jenkins:

jenkins execute shell:

py.test tests || true

it starts. and after it finished I see next log:

Started by user manny
Building in workspace /var/lib/jenkins/workspace/web-services tests
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url https://example.git # timeout=10
Fetching upstream changes from
[web-services tests] $ /bin/sh /tmp/
============================= test session starts ==============================
platform linux -- Python 3.5.1, pytest-2.9.1, py-1.4.31, pluggy-0.3.1
rootdir: /var/lib/jenkins/workspace/web-services tests/tests, inifile:
plugins: asyncio-0.3.0
collected 99 items / 4 errors

tests/bll/ ...... //here goes list of tests

===== 3 failed, 75 passed, 1 skipped, 20 xfailed, 4 error in 76.85 seconds =====
Finished: SUCCESS

jenkins notify Slack:

web-services tests - #44 Back to normal after 19 min (</job/web-services%20tests/44/|Open>)
No Tests found.

No tests found. How to fix it?

sca sca
Answer Source

From the log, we can see that the python script has failed

collected 99 items / 4 errors

And from Jenkins point of view, if any error is encountered, it will give failure as Jenkins uses /bin/sh -xe by default.

So by adding the #!/bin/sh before calling the python script might help in resolving this issue :

    py.test tests