Thank you for your discussion. Combined with unittest, the arrangement is as follows:

For n test cases, need to write a full test_1,test_2?

Apparently not. All you need to do is write the name and parameters of the interface to be tested in the table.

As shown in figure:

Specific code:

Token_emba ('12012341006', '123456') # class variable def begin_req(self,apidata): # print apidata if apidata[1] == ["]: data = eval(apidata[0])() elif apidata[1]! = ['] : Data = eval(apidata[0])(apidata[1]) # input the data to test,data=(mode, URL,body), back = json.loads(req(data, Self.token_1)['res_body']) # req(data,token) YQ = 200 # Set the actual return, if you need to pass the TOKEN header, please be sure to fill in! self.assertEqual(SJ, YQ, error_code(SJ, YQ)) def demo(apidata): def tool(self): Test.begin_req(self,apidata) setattr(tool, '__doc__', u' testattr %s' % STR (apidata[0])) return tool def testall(apidata): for i in range(len(apidata)): setattr(Test,'test_'+str(i+1),demo(apidata[i])) if __name__ == "__main__": SZ = xlrd.open_workbook(fname) SZ = sz.sheet_by_index (0) for I in range(1,sz.nrows): par = str(sz.cell_value(i,1)).split(',') Apidata.append([sz.cell_value(i,0),par]) testall(Apidata) suit = Unittest.makesuite (Test) filename = U '/'.join(os.getcwd().split('/')[:-2]) + u'/Report/ Business logic interface Test Report -test.html' fp = File (filename, 'wb') runner = HTMLTestRunner(fp, title=u' test server new interface test ', description=u' use case execution report ', fname=filename.split('/')[-1]) runner.run(suit)Copy the code

There are many of their own encapsulation of the function, posted is to give you a look at the idea. Our policy is to try not to change the code as often as possible because use cases need to be added or deleted.

That is, write use case tables, view reports in HTML or other files.

The figure shows the test report

Have not understood welcome message discussion.