1
我的python脚本已列出:如何修复python构建错误“ValueError:在<class'__main__中没有这样的测试方法。”
====================================== ====
class ExampleTestCase(unittest.TestCase):
capabilities = None
def setUp(self):
self.driver = webdriver.Remote(desired_capabilities={ "browserName": broswer, "platform": platform, "node": node })
def test_example(self):
self.driver.get("www.360logica.com")
self.assertEqual(self.driver.title, "360logica")
def tearDown(self):
self.driver.quit()
if __name__ == "__main__":
#unittest.main()
args = sys.argv
port = args[1]
platform = args[2]
broswer = args[3]
suite = unittest.TestSuite()
suite.addTest(ExampleTestCase("test_example"))
runner = XMLTestRunner(file('results_ExampleTestCase_%s.xml' % (broswer), "w"))
runner.run(suite)
======================================= =======
运行命令为:
$ ./python.exe Grid_1.py 5555 WINDOW firefox
=========================== ===================
生成错误日志:
$ ./python.exe Grid_1.py 5555 WINDOW firefox
Traceback (most recent call last):
File "Grid_1.py", line 31, in <module>
suite.addTest(ExampleTestCase("test_example"))
File "C:\Python27\Lib\unittest\case.py", line 191, in __init__
(self.__class__, methodName))
ValueError: no such test method in <class '__main__.ExampleTestCase'>: test_example
=================================== ================
请帮帮我。我非常头痛,并且不知道如何修复它。
非常感谢您对这个可贵之处了。 – 2013-02-28 00:15:09
嗨戈登,当我尝试重新定义test_example作为类的一部分时,仍然存在构建错误。但是无论我尝试什么,我都会一次又一次地出现这个错误.....因此,头痛......因为你是专家,你能帮我确定def test_example的最佳位置吗?再次感谢。 – 2013-02-28 00:23:58
我不确切知道这里发生了什么,但我可以指出一些事情。在你的'def setUp()'中调用''node“:node',但节点从不在任何地方列出。解决这个问题后,我可以用你提供的命令运行这个,这是我的输出:http://pastebin.com/hFWmxiUe – GordonsBeard 2013-02-28 00:39:06