有谁知道有什么免费的自动化测试工具可以对 python 代码和 javascript 进行单元测试吗?
请您参考如下方法:
您可能希望将多个测试框架组合在一起。我们团队用 Nose http://code.google.com/p/python-nose/正如@Arbie 指出的那样。
我们还使用 nose 来运行 selenium http://seleniumhq.org/使用 python 驱动程序进行测试,这实际上是我所知道的有效测试操纵 DOM 的 javascript 的唯一方法。尽管我对 WebDriver 作为 selenium 2 的一部分寄予厚望,一旦它稳定下来。在使用 selenium 时,我们不得不对 python 驱动程序进行 Monkey Patch 以使其更像 pythonic。包装 python-selenium 驱动程序,使其发生变化:
selenium.doCommand('waitForElementPresent', 'selector')
进入:
selenium.wait_for_element_present('selector')
然后您可以使用 nose 和 selenium 来运行 QUnit http://docs.jquery.com/Qunit如果您只想测试不一定会更改 DOM 的基本 javascript 函数。
Selenium 集成示例:
def setUp(self):
self.test_url = "http://your_domain"
self.selenium = selenium("localhost", 4444, "*firefox3", self.test_url)
self.selenium.start()
def tearDown(self):
self.selenium.stop()
