有的时候,我们可能需要把编译好的Ranorex测试用bat串起来运行,在bat里面如果想要了解测试是否成功,我们可以用@echo %errorlevel%来获取其状态。
例如,我们编写了一个名叫ReturnValue的测试项目,它将编译出一个ReturnValue.exe的可执行文件,该测试用例只有一句代码:
Validate.IsTrue(true);
我们可以在和exe相同的目录里面编写一个ReturnValue.bat,里面的批处理指令为:
@call ReturnValue.exe
@echo %errorlevel%
这样就会打印出ReturnValue这个测试成功还是失败,如果成功,将会打印0,如果失败就可能是非0值。
当测试的代码是Validate.IsTrue(true);时,ReturnValue.bat的执行结果是:
[2013/03/28 16:19:13.990][Debug ][Logger]: Console logger starting.
[2013/03/28 16:19:14.100][Info ][Test]: Test Suite ‘ReturnValue’ started.
[2013/03/28 16:19:14.115][Info ][Test]: Test Case ‘TestCase’ started.
[2013/03/28 16:19:14.131][Info ][Test]: Test Module ‘ReturnTrue’ started.
[2013/03/28 16:19:14.131][Success][Test]: Test Module ‘ReturnTrue’ completed with status ‘Success’.
[2013/03/28 16:19:14.131][Success][Test]: Test Case ‘TestCase’ completed with status ‘Success’.
[2013/03/28 16:19:14.131][Success][Test]: Test Suite ‘ReturnValue’ completed with status ‘Success’.
[2013/03/28 16:19:14.194][Debug ][Logger]: Console logger stopping.
0
当测试的代码是Validate.IsTrue(true);时,ReturnValue.bat的执行结果是:
[2013/03/28 16:21:02.783][Debug ][Logger]: Console logger starting.
[2013/03/28 16:21:02.893][Info ][Test]: Test Suite ‘ReturnValue’ started.
[2013/03/28 16:21:02.908][Info ][Test]: Test Case ‘TestCase’ started.
[2013/03/28 16:21:02.924][Info ][Test]: Test Module ‘ReturnTrue’ started.
[2013/03/28 16:21:02.987][Failure][Validation]: Condition is not true.
[2013/03/28 16:21:03.049][Error ][Module]: Module execution was aborted because a validation step has failed. Condition is not true
[2013/03/28 16:21:03.236][Failure][Test]: Test Module ‘ReturnTrue’ completed with status ‘Failed’.
[2013/03/28 16:21:03.236][Failure][Test]: Test Case ‘TestCase’ completed with status ‘Failed’.
[2013/03/28 16:21:03.236][Failure][Test]: Test Suite ‘ReturnValue’ completed with status ‘Failed’.
[2013/03/28 16:21:03.299][Debug ][Logger]: Console logger stopping.
-1