0
我有斯卡拉類這樣的:如何模仿scala val提交?
@Component
class SomeClassForTest {
@Autowired
implicit val type: Type = null
...
}
純春天,這個代碼做工精細。但磨片我試圖創建測試用的Mockito:
@RunWith(classOf[JUnitRunner])
class SomeClassForTest {
@InjectMocks
var SomeClassForTest : instance = null
@Spy
val type: Type = new Type()
...
//in before method
MockitoAnnotations.initMocks(this)
}
注入模擬不起作用,直到我寫var
而不是val
類測試:
@Autowired
implicit var type: Type = null
是否有可能在測試類注射val
?