我有這個~/.gradle/gradle.properties:
com.my.path=/path/to/stuff
我在 Scala 測驗中有這個:
class MyTest extends FunSuite {
val path = sys.props.getOrElse("com.my.path", throw new RuntimeException("nope!"))
測驗總是拋出例外,因為com.my.path不在sys.props.
我嘗試按照這里的建議在屬性中添加前綴~/.gradle/gradle.properties,但systemProp.沒有任何區別。
我還嘗試將其添加到我的 build.gradle 中:
test {
systemProperties = System.properties
}
我忘記了我在哪里讀到的,但這會導致測驗運行程式失敗并出現“未找到測驗”錯誤。
我正在使用 IntelliJ FWIW 運行測驗。
uj5u.com熱心網友回復:
任何必需的屬性都必須顯式傳遞給測驗。見https://docs.gradle.org/current/dsl/org.gradle.api.tasks.testing.Test.html
你通過 gradle 屬性
test {
// set a system property for the test JVM(s)
systemProperty 'some.prop', some.prop
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/515725.html
上一篇:如何向我的元組添加排名數字?
