我添加了一个 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##*