robot framework plugin for teamcity

1.6k Views Asked by At

I am running robot framework test through teamcity build. I can get results log.html into artifacts. But is there any plugin in teamcity for robot framework so I can populate results in projects?

update

thanks a lot ! I added py file in suite as below

class TeamCityListener():

    ROBOT_LISTENER_API_VERSION = 2

    def start_suite(self, name, attrs):
        sys.__stdout__.write("##teamcity[testSuiteStarted name='{name}']\n".format(name=name))
        print 'hi'
        sys.__stdout__.flush()

And I called it from teamcity as pybot --listener TeamCityListener.py --console none test.robot But when I run in project I see Step 1/1 and them Success Do I have to add anything on teamcity side? Before running pybot I'm sshing into machine, maybe that's the reason?

1

There are 1 best solutions below

0
On BEST ANSWER

TeamCity has an API for integrating external tools. In short, if your test prints results in a format defined by TeamCity, TeamCity will show the results on the dashboard.

An overview of this API can be found here: https://confluence.jetbrains.com/display/TCDL/Build+Script+Interaction+with+TeamCity

The way I approached this was to create a custom listener. In it, the various methods (start_suite, end_suite, etc) all simply emitted messages in the given format.

For example, the start_suite listener method looks something like this:

class TeamCityListener():
    ...
    def start_suite(self, name, attrs):
        sys.__stdout__.write("##teamcity[testSuiteStarted name='{name}']\n".format(name=name))
        sys.__stdout__.flush()

Other methods are nearly identical, only differing by the actual text that is written to stdout.

Then, when running our tests we use this listener and turn off the default output:

pybot ... --listener TeamCityListener.py --console none ...

You will need to implement some of the other methods of the listener in a similar fashion. For example, end_test and end_suite is where you would report test success or failures. You can also use log_message to have error messages appear in the team city dashboard.