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 自动化测试订购测试用例
基础教程推荐
- 在 iOS8 中无法获得正确的键盘高度值 2022-01-01
- 新的@SystemApi 注解是什么意思,和@hide 有什么区别 2022-01-01
- 可可/目标C(OSX不是iOS)从子对象访问父对象 2022-01-01
- 如何将多个组件添加到 PickerView? 2022-01-01
- 在 Android 模拟器中激活网络位置提供程序? 2022-01-01
- 我的 UIImageView 的任务 2022-01-01
- - (CGRect)convertRect:(CGRect)rect toView:(UIView *)view 如何工作 2022-01-01
- 在 appComponent dagger 2 中动态添加测试模块? 2022-01-01
- Android:STATE_SELECTED不工作 2022-01-01
- 突出显示朗读文本(在 iPhone 的故事书类型应用程序中) 2022-01-01
