sikuli自动化测试html报告输出

The UI Tests should be run automatically. We need to run them automatically, on demand or in given moment in time. A good practice is to create a batch file for running them. This file could be run manually or in part of integrated system or even with Task Scheduler in given time.Sample code for the batch file for running Sikuli UI Tests is:

@echo on

rem the path to the project with test list and tests

set ProjectPath="C:\Work\Tests\ReportingTests"

rem generated the path to the test list

set TestList="%ProjectPath%\TestSuite.sikuli"

rem path to the “Sikuli-IDE” file, which will run the sikuli files

set TestRunner="C:\SikuliX\Sikuli-IDE.bat"

rem run the test-list with the tests

call %TestRunner% -r %TestList%

In the test list we should add a code for integration with HTMLTestRunner. First we need to add a method for creating a new instance of HTMLTestRunner with the correct data and run the test for the given test suite:

def RunSuite(testCase):

#Open the file for the test results

    outfile = open("C:\\Results\\Results.html""w")

#Creating an instance of HTMLTestRunner for the current test list

runner = HTMLTestRunner.HTMLTestRunner(stream=outfile, title=UI

    Tests’, description=‘Suite with all tests’)

#Starting the tests for the given given test suit

    runner.run(suite)

Now at the end of the test list we need to create a test suit with the tests and to call the method for running them:

#Import the package with the test

import UITests

#Creating a variable with the tests

testCaseForUITests=UITests.FirstUITests.FirstUITests

#Creating a new instance of test suite

suite=unittest.TestSuite()

#Add the test to the new test suit

suite.addTest(unittest.TestLoader().loadTestsFromTestCase(testCaseForUITests))

#Call the created method for funning the tests

RunSuite()

After the test are executed the test results are going to be generated in the file that we have specify. When the test are generated we could send them by Email or post somewhere to analyze them.

 

Results

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值