Robotium结果的收集和失败重跑

引用自 http://www.robotium.cn/archives/author/zered

测试用例:

testsuite管理测试用例

测试结果的输出与收集?

InstrumentationTestRunner把输出报告定向到一个Html文档中

测试结果问题的定位?

加入case的执行的关键步骤和截图

执行后crash重跑?

PC端工具每次执行一个case,然后获取到流的返回值,如果返回值中包含”shortMsg=Process crashed”,就说明该用例运行失败程序crash此时进入Crash重试机制,如果多次运行都为crash则在TEST-ALL.xml中记录结果(这里设置为3次重跑,当然你也可以自定义)

[code]  private Boolean doAndroidTestCase(String TestCase){

Boolean isTestOk = false;

for(int i=0;i<3; i++)

{

if(startcmd(TestCase).Contains(CRASH)){

continue; //如果程序Crash,则结束当前循环进入下次循环,直至3次结束

}else{

isTestOk = true;

break;

}

}

return isTestOk;

} [/code]

private string startcmd(string command)
{
Process cmd = new Process();
cmd.StartInfo.FileName = “cmd.exe”;
cmd.StartInfo.UseShellExecute = false;
cmd.StartInfo.RedirectStandardInput = true;
cmd.StartInfo.RedirectStandardOutput = true;
cmd.StartInfo.CreateNoWindow = true;
cmd.Start();
cmd.StandardInput.WriteLine(command);
cmd.StandardInput.WriteLine(“exit”);
cmd.WaitForExit();
string output = cmd.StandardOutput.ReadToEnd();
cmd.Close();
return output;
}

不积跬步,无以至千里
原文地址:https://www.cnblogs.com/melody-emma/p/4260233.html