Closed BryanHunt closed 12 years ago
The problem is that you access the type in xtend differently than in java: List.class => typeof(List). Here is a working example:
package demo
import static org.mockito.Mockito.*
import static org.mockito.MockitoAnnotations.*
import java.util.List
import org.mockito.Mock
describe "Mockito"{
describe "standard"{
val mock = mock(typeof(List))
fact mock should not be null
}
describe "annotation"{
@Mock List mock
before initMocks(this)
fact mock should not be null
}
}
Jnario supports also custom test factories (see http://jnario.org/org/jnario/spec/tests/integration/SpecInstantiationSpec.html). You can create a custom factory for Mockito (see https://github.com/bmwcarit/Jnario/blob/master/org.jnario.examples/specs/gameoflife/MockitoInstantiator.java) and use it in your spec by annotating the root spec with: @InstantiateWith(MockitoInstantiator.
Ah, I got it working. Thanks for your patience.
I'm trying to get Jnario to work with Mockito, and I'm having problems. Here's a simple example:
Here's something else I tried:
Ideally, I'd like to use @Mock, but that requires either the MockitoJUnitRunner which I understand we can't use, or
which does not work either.