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