Example batch execution, and results are shown in html, Python console is also displayed during operation

Download HTMLTestRunner.py put under the Lib python installation directory;

Below to log in, for example, create different .py files,

 

 

==================================================================================================
#runall.py代码如下
import unittest,HTMLTestRunner
import os
def runa():
path=os.getcwd()
print(path)
a=unittest.defaultTestLoader.discover(path,
pattern='login*.py')
al=unittest.TestSuite()
al.addTest(a)
#print(al)
return al
if __name__=="__main__":
#unittest.TextTestRunner().run(runa())
htmlrun=unittest.TextTestRunner()
result=os.path.join(os.getcwd()+"\\result.html") #若无result.html,则会自动创建
print(result)
a=open(result,'wb')
= HTMLTestRunner.HTMLTestRunner htmlrun (Stream = A,
title = 'automated test result',
Description = 'results are as follows:',
the verbosity = 2) #python console shows a process
htmlrun.run (Runa ())
a.close ( )

 

 # Summary: Use the HTMLTestRunner.HTMLTestRunner (stream = **, title = **, description = **, verbosity = 2),

os.getcwd () # Get the current file path; os.path.join (os.getcwd () + "\ a.txt") Get the current path plus the file name;.

 

Guess you like

Origin www.cnblogs.com/canglongdao/p/11986343.html