1
我想弄清楚如何自定義與偵聽器的機器人測試腳本的輸出。我嘗試使用下面的聽衆:爲什麼有所示還是統計數據如何自定義機器人框架測試輸出?
% pybot --listener listen.py --output NONE --log NONE --report NONE --quiet --exitonfailure --outputdir NONE test.robot
[ WARN ] Listener 'listener.py' uses deprecated API version 1. Switch to API version 2 instead.
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
108 980 108 980 0 0 1677 0 --:--:-- --:--:-- --:--:-- 25789
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 17125 100 17125 0 0 55405 0 --:--:-- --:--:-- --:--:-- 229k
我想知道:
from robot.api import logger
class TestListener:
ROBOT_LISTENER_API_VERSION = 2
def __init__(self):
self.pass_count = 0
self.fail_count = 0
self.skip_count = 0
self.error_count = 0
self.total_count = 0
def end_test (self, name, attributes):
if attributes['status'] == 'PASS':
self.pass_count = self.pass_count + 1
else:
self.fail_count = self.fail_count + 1
self.total_count = self.total_count + 1
def close(self):
logger.console("%d tests total, %d passed, %d failed" % (self.total_count,self.pass_count,self.fail_count))
但不知何故,當我運行pybot,我得到下面的輸出即使在使用「--quiet」模式時,以及爲什麼監聽器中logger.console的輸出未顯示。
任何幫助非常感謝! 謝謝!