Batch file 在命令行上完成robotium测试后,如何获取退出代码或退出状态
现在,我编写了一个批处理脚本来运行命令,如下所示:Batch file 在命令行上完成robotium测试后,如何获取退出代码或退出状态,batch-file,command-line,cmd,robotium,exit-code,Batch File,Command Line,Cmd,Robotium,Exit Code,现在,我编写了一个批处理脚本来运行命令,如下所示: adb -s emulator-5556 shell am instrument -e class com.example.test.locationListTest -w com.example.test/android.test.InstrumentationTestRun 然后在控制台上,我得到了类似FAILURE!!!测试运行:5次失败:4次或正常 我使用if errorlevel 0来确定上级命令,但无论上级命令给我什么,它都给我0
adb -s emulator-5556 shell am instrument -e class com.example.test.locationListTest -w com.example.test/android.test.InstrumentationTestRun
然后在控制台上,我得到了类似FAILURE!!!测试运行:5次失败:4次
或正常
我使用if errorlevel 0
来确定上级命令,但无论上级命令给我什么,它都给我0,OK或FAILURE
我需要在批处理脚本中这样做:
if(adb -s emulator-5556 shell ..... test.InstrumentationTestRun == SUCCESS )
do (.........)
else (.........)
试试这个:
@echo off
setlocal
set "adb=adb -s emulator-5556 shell am instrument -e class com.example.test.locationListTest -w com.example.test/android.test.InstrumentationTestRun"
for /f "tokens=*" %%a in ('%adb%^|find /i "Ok"') do (
if not errorlevel 1 (
Echo Success
) else (
echo Failure
)
)
这样,errorlevel将起作用,因为它来自Find 试试这个:
@echo off
setlocal
set "adb=adb -s emulator-5556 shell am instrument -e class com.example.test.locationListTest -w com.example.test/android.test.InstrumentationTestRun"
for /f "tokens=*" %%a in ('%adb%^|find /i "Ok"') do (
if not errorlevel 1 (
Echo Success
) else (
echo Failure
)
)
这样,errorlevel将起作用,因为它来自Find 试试这个:
@echo off
setlocal
set "adb=adb -s emulator-5556 shell am instrument -e class com.example.test.locationListTest -w com.example.test/android.test.InstrumentationTestRun"
for /f "tokens=*" %%a in ('%adb%^|find /i "Ok"') do (
if not errorlevel 1 (
Echo Success
) else (
echo Failure
)
)
这样,errorlevel将起作用,因为它来自Find 试试这个:
@echo off
setlocal
set "adb=adb -s emulator-5556 shell am instrument -e class com.example.test.locationListTest -w com.example.test/android.test.InstrumentationTestRun"
for /f "tokens=*" %%a in ('%adb%^|find /i "Ok"') do (
if not errorlevel 1 (
Echo Success
) else (
echo Failure
)
)
这样,errorlevel将起作用,因为它来自Find
如果errorlevel 0
始终为真
如果不是errorlevel 1,则在使用该行样式进行测试时需要使用
。如果errorlevel 0
始终为真
如果不是errorlevel 1,则在使用该行样式进行测试时需要使用。如果errorlevel 0
始终为真
如果不是errorlevel 1,则在使用该行样式进行测试时需要使用。如果errorlevel 0
始终为真
如果不是错误级别1,您需要使用。当您使用该样式的行进行测试时,您需要使用,例如:
adb -s emulator-5556 shell am instrument -e class com.example.test.locationListTest -w com.example.test/android.test.InstrumentationTestRun | grep "Failures"
if [ $? -eq 0 ]; then
echo "## TEST FAILED ##"
exit 1
fi
简单的事情怎么样,比如:
adb -s emulator-5556 shell am instrument -e class com.example.test.locationListTest -w com.example.test/android.test.InstrumentationTestRun | grep "Failures"
if [ $? -eq 0 ]; then
echo "## TEST FAILED ##"
exit 1
fi
简单的事情怎么样,比如:
adb -s emulator-5556 shell am instrument -e class com.example.test.locationListTest -w com.example.test/android.test.InstrumentationTestRun | grep "Failures"
if [ $? -eq 0 ]; then
echo "## TEST FAILED ##"
exit 1
fi
简单的事情怎么样,比如:
adb -s emulator-5556 shell am instrument -e class com.example.test.locationListTest -w com.example.test/android.test.InstrumentationTestRun | grep "Failures"
if [ $? -eq 0 ]; then
echo "## TEST FAILED ##"
exit 1
fi
您可以使用gradle运行仪器测试,而不是通过adb进行测试
下面是一个执行此操作的bash脚本示例:
#!/bin/bash
CMD="./gradlew connectedAndroidTest"
$CMD
RESULT=$?
if [ $RESULT -ne 0 ]; then
echo "failed $CMD"
exit 1
fi
exit 0
您可以使用gradle运行仪器测试,而不是通过adb进行测试
下面是一个执行此操作的bash脚本示例:
#!/bin/bash
CMD="./gradlew connectedAndroidTest"
$CMD
RESULT=$?
if [ $RESULT -ne 0 ]; then
echo "failed $CMD"
exit 1
fi
exit 0
您可以使用gradle运行仪器测试,而不是通过adb进行测试
下面是一个执行此操作的bash脚本示例:
#!/bin/bash
CMD="./gradlew connectedAndroidTest"
$CMD
RESULT=$?
if [ $RESULT -ne 0 ]; then
echo "failed $CMD"
exit 1
fi
exit 0
您可以使用gradle运行仪器测试,而不是通过adb进行测试
下面是一个执行此操作的bash脚本示例:
#!/bin/bash
CMD="./gradlew connectedAndroidTest"
$CMD
RESULT=$?
if [ $RESULT -ne 0 ]; then
echo "failed $CMD"
exit 1
fi
exit 0