【发布时间】:2012-03-10 11:31:20
【问题描述】:
我的自动化脚本生成了很多日志文件,这些文件还记录了脚本的启动时间和完成时间。在相同的地方有一些重复,个别测试失败了。
我希望汇总时间来计算运行所有脚本(约 200 个脚本,约 8000 个测试用例)所需的时间。问题是有时脚本在没有运行单个案例的情况下中止,框架仍然将时间记录到日志文件中。我想做类似的事情:
Pick specific files with the same script name (as a single script can be run multiple times and has a log file for each of these runs in its name)
Read the Log file for a single script
If FAIL value = (total test cases) then skip the log file
If ABORT value = (total test cases) then skip the log file
If PASS value = (total test cases -1) then record the Start and End times to the output file
Goto the next script in the same name set
Goto the next set of script files
此外,一旦上述操作完成,我想汇总和平均时间,并找到每个脚本和完整运行的平均时间。
有没有使用 shell 脚本或 DOS 批处理的简单方法?我不想为此实现编写一个成熟的程序?如果有人能告知VBScript是否可以做到这一点以及如何做到这一点,那就太好了?
文件详情:
日志文件的名称:
TestScriptA_20120201.LOG
TestScriptA_20120202.LOG
TestScriptA_20120203.LOG
TestScriptB_20120201.LOG
TestScriptB_20120202.LOG
TestScriptC_20120202.LOG
TestScriptD_20120203.LOG
文件内容:
Report File: TestScriptA_20120203.LOG
Date Created: 14-02-2012
Time Started: 09:21:03
Test Database: staging
Processor: proc_stage
Test Login: ABC
Test Date : 14-02-2012
Test #1 Status : Pass
Purpose = First Test
DataFile = master1.tda
StepName = TS1 - Test Step 1
Test #2 Status : Pass
Purpose = First Test
DataFile = master2.tda
StepName = TS1 - Test Step 2
Test Step Results: First Test
Total Tests: 2
Tests run: 2
Aborted Tests: 0
Passed Tests: 2
Failed Tests: 0
Script finished at 09:26:45 on 14-02-2012
Execution Time : 00:05:42
------------------------------- End Of Report -----------------------------
【问题讨论】:
-
这可以通过一个 .BATch 文件来完成,尽管方式不是很简单。请张贴文件名的具体细节(脚本和日志文件的名称?我们如何知道多个文件属于同一个脚本?)行的格式是什么? FAIL、ABORT 和 PASS 值出现在哪里?开始和结束时间在哪里,格式是什么?等等……
-
@Aacini 添加了文件名和内容。
标签: shell scripting vbscript batch-file