问题
I am working in the database domain. Few days back I started working on unit testing using python's most popular package i.e. unittest
. I am totally new to python unittest.
I want to test some database opreations like Add/update/delete with different database servers.
I want the final test result as below
sample result
-------------------
==============
server 1: 20 passed 10 failed
server 2: 10 passed 20 failed
==============
and so on...
My current class structure is
Class DB_Test(uniittest.Testcase):
def setUpClass(self):
<generate predata(like create server, connect to server)>
def runTest(self):
for server in server_list:
add_db(<server_data>,<db_data>)
def tearDown(self):
<clean the predata>
So, How to customise the code so that I can capture the test result serverwise? Now its showing default test result with ok & fail.
来源:https://stackoverflow.com/questions/39018204/how-to-customize-python-unittest-tests-output