【发布时间】:2017-02-09 12:17:54
【问题描述】:
我有以下测试...
import org.scalatest.junit.JUnitRunner
...
@PowerMockRunnerDelegate(classOf[JUnitRunner])
@PrepareForTest(Array(classOf[AuditLog]))
class ConnectorAPITest extends path.FreeSpec with ShouldMatchers {
"Mocked Tests" - {
println("This got called in the mocked tests.")
PowerMockito.mockStatic(classOf[AuditLog]);
...
}
}
但是当我跑步时,我得到...
An exception or error caused a run to abort: The class com.paxata.services.log.AuditLog not prepared for test.
To prepare this class, add class to the '@PrepareForTest' annotation.
In case if you don't use this annotation, add the annotation on class or method level.
org.powermock.api.mockito.ClassNotPreparedException:
The class com.paxata.services.log.AuditLog not prepared for test.
To prepare this class, add class to the '@PrepareForTest' annotation.
鉴于注释已经存在,这没有意义?它是 Scala 测试的特质吗?
【问题讨论】:
-
如果你尝试在注解中使用完整的类路径会发生什么?
-
你可以试试
@PrepareForTest({AuditLog.class})代替那个。
标签: scala powermock scalatest powermockito