我已經繼承了大約1000次測試的項目。直到最近,當我輸入gradle clean test
命令時,它們全部被執行。爲什麼在我的Gradle構建中不執行某些測試?
從一天到另一天,一些測試停止包含在測試統計中(Gradle和Idea在所有測試執行結束時輸出的已通過,失敗和忽略的測試數)。代碼仍然存在,測試不會被忽略。也沒有修改任何構建腳本。當我在IntelliJ Idea中運行測試時,它們被執行(即沒有編譯器錯誤可以解釋爲什麼測試不運行)。
我相信這些測試是被執行的,但他們的結果並不包含在整體統計中,原因如下。我執行了命令gradle --debug --rerun-tasks clean test > 2017_11_24_gradle.log
。然後,我查找了2017_11_24_gradle.log
文件(grep「com.mycompany.comm.CommApplicationTests」2017_11_24_gradle.log)中丟失的測試com.mycompany.comm.CommApplicationTests
中的一個。
這是grep的輸出:
17:00:54.861 [QUIET] [system.out] 17:00:54.860 [DEBUG] [org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor] Executing test class com.mycompany.comm.CommApplicationTests
17:00:54.867 [DEBUG] [TestEventLogger] com.mycompany.comm.CommApplicationTests STARTED
17:00:55.169 [DEBUG] [TestEventLogger] com.mycompany.comm.CommApplicationTests > validateProtocol STARTED
17:00:55.875 [DEBUG] [TestEventLogger] com.mycompany.comm.CommApplicationTests > validateProtocol STANDARD_OUT
17:00:57.272 [DEBUG] [TestEventLogger] com.mycompany.comm.CommApplicationTests > validateProtocol PASSED
17:00:57.273 [DEBUG] [TestEventLogger] com.mycompany.comm.CommApplicationTests > contextLoads STARTED
17:00:57.273 [DEBUG] [TestEventLogger] com.mycompany.comm.CommApplicationTests > contextLoads PASSED
17:00:57.274 [DEBUG] [TestEventLogger] com.mycompany.comm.CommApplicationTests PASSED
由此我得出結論,測試被執行。
其可以或可以不考慮非夾雜物的一些測試結果的唯一事情可疑是這樣的:
16:37:47.251 [ERROR] [system.err] *** java.lang.instrument ASSERTION FAILED ***: "!errorOutstanding" with message transform method call failed at JPLISAgent.c line: 844
16:37:47.343 [ERROR] [system.err] *** java.lang.instrument ASSERTION FAILED ***: "!errorOutstanding" with message transform method call failed at JPLISAgent.c line: 844
16:37:47.343 [ERROR] [system.err] *** java.lang.instrument ASSERTION FAILED ***: "!errorOutstanding" with message transform method call failed at JPLISAgent.c line: 844
16:37:47.346 [ERROR] [system.err] *** java.lang.instrument ASSERTION FAILED ***: "!errorOutstanding" with message transform method call failed at JPLISAgent.c line: 844
16:37:47.346 [ERROR] [system.err] *** java.lang.instrument ASSERTION FAILED ***: "!errorOutstanding" with message transform method call failed at JPLISAgent.c line: 844
16:37:47.347 [ERROR] [system.err] *** java.lang.instrument ASSERTION FAILED ***: "!errorOutstanding" with message transform method call failed at JPLISAgent.c line: 844
這些消息的gradle --debug --rerun-tasks clean test
執行期間被輸出到System.err
。
我該如何解決或解決erorr問題(即確保所有已執行的測試都反映在Gradle最後打印的最終統計信息(通過,失敗和忽略的測試數量))?
更新1(2017年11月27日10:49 MSK):
它看起來像下面的code fragment發生錯誤(評論// Line 844
):
if (!errorOutstanding) {
jplis_assert(agent->mInstrumentationImpl != NULL);
jplis_assert(agent->mTransform != NULL);
transformedBufferObject = (*jnienv)->CallObjectMethod(
jnienv,
agent->mInstrumentationImpl,
agent->mTransform,
loaderObject,
classNameStringObject,
classBeingRedefined,
protectionDomain,
classFileBufferObject,
is_retransformer);
errorOutstanding = checkForAndClearThrowable(jnienv);
jplis_assert_msg(!errorOutstanding, "transform method call failed"); // Line 844
}
更新2(27.11。 2017 16:51 MSK): Mac上不會發生此錯誤(Gradle報告正確的總數,通過和失敗的測試數)。
更新3(2017年11月29日12:48 MSK):
我使用Java 1.8.0_152和搖籃2.14。由於客戶要求,我無法升級Gradle版本。
java -version
java version "1.8.0_152"
Java(TM) SE Runtime Environment (build 1.8.0_152-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.152-b16, mixed mode)
gradle -version
------------------------------------------------------------
Gradle 2.14
------------------------------------------------------------
Build time: 2016-06-14 07:16:37 UTC
Revision: cba5fea19f1e0c6a00cc904828a6ec4e11739abc
Groovy: 2.4.4
Ant: Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM: 1.8.0_152 (Oracle Corporation 25.152-b16)
OS: Windows 10 10.0 amd64
由於您的警告來自JDK,因此在有/無錯誤的系統上使用哪個Java版本可能更有意義。此外,gradle版本可能是有意義的。最後,Gradle論壇可能是獲得這方面支持的更好的地方。 – tkruse
關於Java和Gradle版本,請參閱更新3。 –