def
と@Test
注釈は必要ありません。次に例を示します。
import org.scalatest.junit.JUnitRunner
import org.junit.runner.RunWith
import org.scalatest.FlatSpec
import org.scalatest.junit.ShouldMatchersForJUnit
@RunWith(classOf[JUnitRunner])
class SpelHelperSpec extends FlatSpec with ShouldMatchersForJUnit {
"SpelHelper" should "register and evaluate functions " in {
new SpelHelper()
.registerFunctionsFromClass(classOf[Functions])
.evalExpression(
"#test('check')", new {}, classOf[String]) should equal ("check")
}
it should "not register non public methods " in {
val spelHelper = new SpelHelper()
.registerFunctionsFromClass(classOf[Functions])
evaluating { spelHelper.evalExpression("#testNonPublic('check')",
new {}, classOf[String]) } should produce [SpelEvaluationException]
}
}
Source
デフォルトでは、すべてのScalaTestをJUnitRunnerで実行できますか?その理由は、Gradleからテストを実行したいと思います.JUnitRunnerはより優れた統合機能を提供します。 –