問題描述
我添加了一個 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##*
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!