2014-10-03 197 views
0

我想測試我的單元測試代碼,但是當我嘗試運行它,它只是說單元測試沒有運行

Finding files... done. 
Importing test modules ... done. 

---------------------------------------------------------------------- 
Ran 0 tests in 0.000s 

OK 

爲什麼不工作?

from Graph import Graph 
import unittest 

class GraphTest: 

    def setUp(self): 
     self.graph = Graph() 
     for i in range(5): 
      self.graph.addNode(i,"Node"+i) 
     self.graph.addEdge(1,5,"Edge1,5") 
     self.graph.addEdge(5,1,"Edge5,1") 
     self.graph.addEdge(3,2,"Edge3,2") 

    def test_Connected(self): 
     self.assertTrue(self.graph.isConnected(1,5)) 
     self.assertTrue(self.graph.isConnected(5,1)) 
     self.assertTrue(self.graph.isConnected(3,2)) 
     self.assertFalse(self.graph.isConnected(2,3)) 
     self.assertFalse(self.graph.isConnected(1,4)) 


if __name__ == '__main__': 
    unittest.main() 

回答

3

你應該讓你的GraphTestunittest.TestCase

一個子類
相關問題