用于在金字塔下启用robotframework测试的便利包。
pyramid_robot的Python项目详细描述
使用robotframework进行金字塔测试
最后,金字塔得到了它的机器人。
这是一个方便的包,使机器人框架测试在金字塔。机器人 框架是用于验收测试和 验收测试驱动开发(ATDD)围绕硒2。它把一切 Asko Soukka的RobotSuite使 带有unittest和webtest http客户端/服务器实用程序的robotframework。
由于robotsuite与plone.testing层一起工作,我们需要在测试中设置一个 样板。这是因为robotsuite最初设计用于 plone测试框架,但是我们完全脱离了它,包括 一种按照robotsuite的期望创建测试层的方法。
只需设置您的测试样板如下:
import os import robotsuite import unittest from webtest import http from paste.deploy import loadapp from pyramid_robot.layer import Layer, layered class myPyramidLayer(Layer): defaultBases = () def setUp(self): conf_dir = os.path.dirname(__file__) app = loadapp('config:test.ini', relative_to=conf_dir) self.server = http.StopableWSGIServer.create(app, port=8080) def tearDown(self): self.server.shutdown() PYRAMIDROBOTLAYER = myPyramidLayer()
您应该提供一个有效的粘贴部署.ini文件,用于在 测试。这可以类似于您用于运行应用程序的自定义 你的测试需要。样板文件在测试文件夹中查找此文件。那么 我们将创建一个侦听指定端口的服务器。参见WebTest 其他自定义的文档。
然后我们定义测试套件如下:
def test_suite(): suite = unittest.TestSuite() current_dir = os.path.abspath(os.path.dirname(__file__)) robot_dir = os.path.join(current_dir, 'robot') robot_tests = [ os.path.join('robot', doc) for doc in os.listdir(robot_dir) if doc.endswith('.robot') and doc.startswith('test_') ] for test in robot_tests: suite.addTests([ layered(robotsuite.RobotTestSuite(test), layer=PYRAMIDROBOTLAYER), ]) return suite
这将准备套件并搜索任何扩展名为 .robot在测试文件夹中的robot文件夹中。
示例
您可以在 测试文件夹。
缺点
称之为缺点,我称之为功能;)
只能使用zope.testing.testrunner运行测试,否则 将被忽略。我想也可以用其他的测试运行程序 像nose一样,欢迎捐款。
您可以使用 zope.testing.testrunner就像根包中包含的一样。只要做:
$ python bootstrap.py $ ./bin/buildout
然后,为了能够运行示例测试:
$ ./bin/test
文件
有关如何使用它的资源,请参阅robotframework文档:
http://code.google.com/p/robotframework/
http://code.google.com/p/robotframework/wiki/HowToWriteGoodTestCases
http://robotframework.googlecode.com/hg/doc/userguide/RobotFrameworkUserGuide.html?r=2.7.6
http://robotframework.googlecode.com/hg/doc/libraries/BuiltIn.html?r=2.7.6
http://rtomac.github.com/robotframework-selenium2library/doc/Selenium2Library.html
更改日志
1.1(2015-08-31)
- 增加了Python3.4支持。
1.0(2013-07-02)
- 初始版本