~ read.

How to get list of failed TeamCity tests using python and Allure reports

In our Selenium framework we made a custom JUnitRunner that can accept list of test suites that we would like to run, or exclude. For that in Team City we made special parameter tab where you can specify package and suite name that you want to run. It can be single test suite, or a list of them. In case if you don't want to run specific package, or suite you just mark it as !{TEST_SUITE_NAME} . It's pretty handy when you have more then 800 tests. At the moment the whole suite runs for more then 2 hours in 8 threads (terrible i know, but we're working on it) and in case when we have 20-40 tests failing because of 1 or couple common problems, then for us it's more handy to run only failed test suites once again when we fix the problem. For this reason we made this custom behaviour. But in the past, to get this list of failing test suites, we had manually to collect list of failing test suites by copy pasting them from our Allure reports - not nice when you have to do that frequently. That's why i love automation - because you can make machine do the routing work for you :) . So, i made a small and nice python script (that's why i love python very much - when you need to do something nice and quick, you can rely on it) that downloads team city artifacts, parses json data and outputs in sorted list all failed or broken test suites. I know that this scenario is quite custom and project - specific, but maybe someone will have similar problem and will just modify my script easily to fit their needs.

To run this script you just need to type in your console :

python teamCityFailedTestSuites.py -url={YOUR_FAILED_JOB_URL}

Of course typing this every time in console is not that nice, so i made a small allias in my .aliases file :

function getFailedTestsFromTeamCity() {
    python ~/Downloads/teamCityFailedTests.py -url=$1
alias tcFailedTests=getFailedTestsFromTeamCity

So now i just type tcFailedTests {TEAM_CITY_FAILED_JOB_URL} and get nice output.

P.S. this script was made for mac users in first place, so if you are linux or windows user, then most probably you will need to modify DOWNLOAD_URL in the script.

comments powered by Disqus
comments powered by Disqus