問題描述
我添加了一個(gè) suite()
方法來按照我想要的方式對(duì)我的測(cè)試進(jìn)行排序,因此當(dāng)我通過 Android JUnit
運(yùn)行它時(shí),它們會(huì)相應(yīng)地執(zhí)行.但后來我注意到,當(dāng)我使用 Spoon 執(zhí)行時(shí),使用 cmd 的執(zhí)行,我的測(cè)試用例按字母順序執(zhí)行,這是默認(rèn)順序.
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.
為什么會(huì)發(fā)生這種情況?如果不重命名我的測(cè)試用例,您將如何應(yīng)對(duì)?
Why does this happen and how would you counter it without renaming my test cases?
推薦答案
我和你有同樣的問題;我需要一個(gè)特定的順序來運(yùn)行我的測(cè)試.我正在測(cè)試的應(yīng)用程序太復(fù)雜,無法以不可預(yù)測(cè)的順序運(yùn)行.我的解決方案是這樣的:
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
}
}
現(xiàn)在,您可以使用如下命令執(zhí)行特定類:
gradle 勺子 -PspoonClassName=<com.your.pakage.ClassName>
gradle spoon -PspoonClassName=< com.your.pakage.ClassName>
接下來,在您的 Android 項(xiàng)目的根目錄下創(chuàng)建一個(gè)文件: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##*
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!