Asserting Number of executed unit-tests

53 Views Asked by At

I am using Jenkins to run unit-tests on a Django project via django-jenkins.

Recently, I found that some of the unit-tests wasn't being executed (someone had mistakenly changed an import, causing Jenkins to miss some of the unit-test files).

Is there a way to assert on the number of tests that Jenkins executes?, or the number of test-packages?

1

There are 1 best solutions below

0
kmmbvnr On

It could be tricky in python.

But you could add additional shell command that just looks into junit report.

cat reports/junit.xml | grep 'classname="your.missing.test.name"'

command would fail if grep doesn't found test record.

Or do the sudo apt-get install libxml-xpath-perl and assert on tests attibute value

[ $(xpath  -q -e '//@tests' reports/junit.xml) == 'tests="1"' ]