import unittest
import HtmlTestRunner
import os
from Ultimatix_login import ultimatix_login1
from searchtest import searchtest
directory1=os.getcwd()
class main_test(unittest.TestCase):
def test_Issue(self):
test1=unittest.TestLoader().loadTestsFromTestCase(ultimatix_login1)
tests2=unittest.TestLoader().loadTestsFromTestCase(searchtest)
#combining both the test cases into one suite
suite=unittest.TestSuite([test1,tests2])
outfile=open(directory1,"\maintest.html","w")
runner1=HtmlTestRunner.HTMLTestRunner(
output=outfile,
report_title="test_report",
descriptions="Main_test"
)
runner1.run(suite)
#opening the report file
#outfile=open(dir +"\testreport.html","w")
if __name__=="__main__":
unittest.main()
我正在尝试生成html测试报告,但测试用例正在执行,但是html报告没有生成请帮我解决这个问题。 谢谢。
答案 0 :(得分:0)
此行不正确:
outfile=open(directory1,"\maintest.html","w")
根据documentation of the built-in open
function,预计前三个论点是
您调用该函数的方式是传递以下参数:
directory1
"\maintest.html"
"w"
- 这是错误的,预计会出现整数。您似乎确实希望使用<directory1>\maintest.html
作为文件路径,并使用"w"
作为开放模式。
为此,请使用os.path.join
功能:
outfile = open(os.path.join(directory1, "maintest.html"), "w")
(请注意,您必须省略\
,这无论如何都会something different。)