import sys
from unittest import TestCase
import nose
from nose.tools import set_trace
class CollectPlugin(object):
enabled = True
name = "test-collector"
score = 100
def options(self, parser, env):
pass
def configure(self, options, conf):
self.tests = []
def startTest(self, test):
self.tests.append(test)
class MyTestCase(TestCase):
def test_long_integration(self):
pass
def test_end_to_end_something(self):
pass
if __name__ == '__main__':
# this code will run just this file, change module_name to something
# else to make it work for folder structure, etc
module_name = sys.modules[__name__].__file__
plugin = CollectPlugin()
result = nose.run(argv=[sys.argv[0],
module_name,
' collect-only',
],
addplugins=[plugin],)
for test in plugin.tests:
print test.id()
有几种方法可以实现这一点:一种是使用带有
collect-only
的xunit插件运行nose并解析生成的junitxml文件。或者,您可以添加一个捕获测试名称的基本插件,如下所示:您的测试信息都捕获在
plugin.test
结构中。你知道吗相关问题 更多 >
编程相关推荐