Groovy Mockito存根-NullPointerException
我是莫基托的新手。这看起来是一个非常简单的测试,但失败了。我正在编写这个Groovy测试,但它不起作用Groovy Mockito存根-NullPointerException,groovy,mockito,junit4,Groovy,Mockito,Junit4,我是莫基托的新手。这看起来是一个非常简单的测试,但失败了。我正在编写这个Groovy测试,但它不起作用 class Test { class Inner{ public String greet(){ return "hello" } } @org.junit.Test void test(){ Inner inner = mock(Inner.class) when(inner.greet()).thenReturn("hi")
class Test {
class Inner{
public String greet(){
return "hello"
}
}
@org.junit.Test
void test(){
Inner inner = mock(Inner.class)
when(inner.greet()).thenReturn("hi")
println inner.greet() // throws java.lang.NullPointerException
}
}看起来Mockito和Groovy在一起玩得不好。不过有一个解决办法-我计划切换回旧的Java、Spring和Junit组合。斯波克还破坏了我现有的Spring测试。怎么会呢?我不太明白