Serhiy
Serhiy

Reputation: 1981

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:

#!/bin/sh
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 https://example.org/m.git
 ...
 ...
[web-services tests] $ /bin/sh /tmp/hudson1759686215204688979.sh
============================= 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/test_action_manager.py ......  //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?

Upvotes: 0

Views: 1555

Answers (3)

sca
sca

Reputation: 39

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 :

    #!/bin/sh
    py.test tests

Upvotes: 0

RvdK
RvdK

Reputation: 19800

Jenkins marks the build success/failed depending on the exit code. 0 is success, else failed.

Exitcode of Py.Test is 0 when there are no errors. When there are 1 or more errors, not 0 (maybe 1, no idea exactly).

Solution:

  • Wrap your call into a seperate shellscript and ignore the exitcode
  • Change Jenkins job to 'your command || true'

Upvotes: 1

Davy
Davy

Reputation: 1796

Run the same test manually (outside of Jenkins) and check the error there. Could be a problem is test collection, or just a test failure itself.

Also: please post full logs so we can better check what is going on

Upvotes: 0

Related Questions