如何计算我的通过失败测试用例并在执行结束时打印
How to Count my pass fail test case and print at the end of execution
我有多个测试用例,我想写一个通用的方法,可以计算所有失败或通过的测试用例,并在执行结束时打印总的通过和失败测试用例。
除了使用 Class 来计算通过和失败的总数之外,您还可以实现如下方法:
int pass=0;
int fail=0;
for(int i=0;i<testCasescount;i++)
{
//read the input using Console.ReadLine();
//check whether the test case is a pass or fail and appropriately increment the counter
}
//executed after the for loop i.e. all the test cases
Console.WriteLine(pass);
Console.WriteLine(fail);
添加 2 个值为 0 的全局参数(varSuccess、varFail)。
每次您根据结果验证任何内容时,只需添加到任一值即可。当测试 运行 完成时,用这些值做任何你想做的事(例如,将它们写入报告文件、控制台等)。
int Failed = 0;
int Passed = 0;
var TestCases = TestSuite.Current.SelectedRunConfig.GetActiveTestContainers();
foreach(var testcase in TestCases){
{if(testcase.IsTestCase){ //To Handle Smart Folders
if(testcase.Status.ToString()=="Failed")
{
Failed++;
}
Passed++;
}
}
}
Report.Log(ReportLevel.Info, "Passed Count :"+Passed);
Report.Log(ReportLevel.Info, "Failed Count :"+Failed);
}
我有多个测试用例,我想写一个通用的方法,可以计算所有失败或通过的测试用例,并在执行结束时打印总的通过和失败测试用例。
除了使用 Class 来计算通过和失败的总数之外,您还可以实现如下方法:
int pass=0;
int fail=0;
for(int i=0;i<testCasescount;i++)
{
//read the input using Console.ReadLine();
//check whether the test case is a pass or fail and appropriately increment the counter
}
//executed after the for loop i.e. all the test cases
Console.WriteLine(pass);
Console.WriteLine(fail);
添加 2 个值为 0 的全局参数(varSuccess、varFail)。 每次您根据结果验证任何内容时,只需添加到任一值即可。当测试 运行 完成时,用这些值做任何你想做的事(例如,将它们写入报告文件、控制台等)。
int Failed = 0;
int Passed = 0;
var TestCases = TestSuite.Current.SelectedRunConfig.GetActiveTestContainers();
foreach(var testcase in TestCases){
{if(testcase.IsTestCase){ //To Handle Smart Folders
if(testcase.Status.ToString()=="Failed")
{
Failed++;
}
Passed++;
}
}
}
Report.Log(ReportLevel.Info, "Passed Count :"+Passed);
Report.Log(ReportLevel.Info, "Failed Count :"+Failed);
}