3

I have a script call run_test.py, here's the content:-

if __name__ == '__main__':
    nose.main(argv=sys.argv)

Running all my tests is as simple as doing this:

run_test.py unittests/test_*.py

I'm trying to now incorperate the output reporting for this into teamcity. I'm referring to this https://github.com/JetBrains/teamcity-messages

I tried changing all my unittests/test_*.py program following the documentation. It works if running the test individually like this:-

unittest/test_one.py

But it does not work when running it thru nose, like this:

run_test.py unittest/test_one.py

According to the documentation link, it says that nose reporting is enabled automatically under TeamCity build. I don't quite get what that means.

Is there anything that i'm missing out here?

Any help is greatly appreciated. Thanks.

lionel319
  • 1,180
  • 2
  • 17
  • 31

2 Answers2

0

have a look at the xunit plugin of nose. it will generate an xml file with the results => which jenkins and teamcity can use.

some documentation for teamcity

this post tells you how to enable the plugin in your test script

if __name__ == '__main__':
    argv = sys.argv[:]
    argv.insert(1, "--with-xunit")
    nose.main(argv=argv)
studioj
  • 1,300
  • 17
  • 32
0

I finally found out the way to achieve that. Here's what i modified in my run_test.py

#!/usr/bin/env python

import os
import sys
import unittest

from teamcity import is_running_under_teamcity
from teamcity.unittestpy import TeamcityTestRunner



loader = unittest.TestLoader()
start_dir = sys.argv[1]
suite = loader.discover(start_dir, pattern='test_*.py')

#runner = unittest.TextTestRunner()
runner = TeamcityTestRunner(verbosity=2)
runner.run(suite)
lionel319
  • 1,180
  • 2
  • 17
  • 31