How to order test cases for Spoon Automated Testing in Android?(如何在 Android 中为 Spoon 自动化测试订购测试用例?)
问题描述
我添加了一个 suite() 方法来按照我想要的方式对我的测试进行排序,因此当我通过 Android JUnit 运行它时,它们会相应地执行.但后来我注意到,当我使用 Spoon 执行时,使用 cmd 的执行,我的测试用例按字母顺序执行,这是默认顺序.
I have added a suite() method to order my tests the way I want them and thus when I run it through Android JUnit they are executed accordingly. But then I noticed that when I use the Spoon execution, the one using cmd, my test cases are executed alphabetically which is the default order.
为什么会发生这种情况?如果不重命名我的测试用例,您将如何应对?
Why does this happen and how would you counter it without renaming my test cases?
推荐答案
我和你有同样的问题;我需要一个特定的顺序来运行我的测试.我正在测试的应用程序太复杂,无法以不可预测的顺序运行.我的解决方案是这样的:
I have the same issue as you; I require a specific order that my test need to be ran in. The app I am testing is too complicated to run in an unpredictable order. My solution was this:
将此添加到您的 build.gradle:
spoon {
if (project.hasProperty('spoonClassName')){
className = project.spoonClassName
}
}
现在,您可以使用如下命令执行特定类:
gradle 勺子 -PspoonClassName=<com.your.pakage.ClassName>
gradle spoon -PspoonClassName=< com.your.pakage.ClassName>
接下来,在您的 Android 项目的根目录下创建一个文件:runAllTests.sh
编辑您的 .sh 使其如下所示:
Edit your .sh to look like this:
#!/bin/sh
date +%b-%dT%H.%M > timestamp.out
sites="$HOME"/path/to/project/root
timestamp="$(cat "$sites"/timestamp.out)"
result_folder="$sites"/results
destdir="$result_folder/Results-$timestamp"
mkdir -p "$destdir"
echo "Directory created: ${destdir##*
本文标题为:如何在 Android 中为 Spoon 自动化测试订购测试用例
基础教程推荐
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
