Skip to main content

One other way around this is to use @Mock annotation instead. Doesn't work in all cases, but looks much sexier :)

Here's an example:

@RunWith(MockitoJUnitRunner.class) public class FooTests { @Mock public Foo<Bar> fooMock; @Test public void testFoo() { when(fooMock.getValue()).thenReturn(new Bar()); } } 

The MockitoJUnitRunnerMockitoJUnitRunner initializes the fields annotated with @Mock@Mock.

One other way around this is to use @Mock annotation instead. Doesn't work in all cases, but looks much sexier :)

Here's an example:

@RunWith(MockitoJUnitRunner.class) public class FooTests { @Mock public Foo<Bar> fooMock; @Test public void testFoo() { when(fooMock.getValue()).thenReturn(new Bar()); } } 

The MockitoJUnitRunner initializes the fields annotated with @Mock.

One other way around this is to use @Mock annotation instead. Doesn't work in all cases, but looks much sexier :)

Here's an example:

@RunWith(MockitoJUnitRunner.class) public class FooTests { @Mock public Foo<Bar> fooMock; @Test public void testFoo() { when(fooMock.getValue()).thenReturn(new Bar()); } } 

The MockitoJUnitRunner initializes the fields annotated with @Mock.

added requested example
Source Link
Björn Pollex
  • 77.1k
  • 30
  • 206
  • 290

One other way around this is to use @Mock annotation instead. Doesn't work in all cases, but looks much sexier :)

Here's an example:

@RunWith(MockitoJUnitRunner.class) public class FooTests { @Mock public Foo<Bar> fooMock; @Test public void testFoo() { when(fooMock.getValue()).thenReturn(new Bar()); } } 

The MockitoJUnitRunner initializes the fields annotated with @Mock.

One other way around this is to use @Mock annotation instead. Doesn't work in all cases, but looks much sexier :)

One other way around this is to use @Mock annotation instead. Doesn't work in all cases, but looks much sexier :)

Here's an example:

@RunWith(MockitoJUnitRunner.class) public class FooTests { @Mock public Foo<Bar> fooMock; @Test public void testFoo() { when(fooMock.getValue()).thenReturn(new Bar()); } } 

The MockitoJUnitRunner initializes the fields annotated with @Mock.

added 2 characters in body
Source Link
palacsint
  • 29k
  • 11
  • 85
  • 113

One other way around this is to use @Mock@Mock annotation instead. Doesn't work in all cases, but looks much sexier :)

One other way around this is to use @Mock annotation instead. Doesn't work in all cases, but looks much sexier :)

One other way around this is to use @Mock annotation instead. Doesn't work in all cases, but looks much sexier :)

Source Link
zkMarek
  • 5.6k
  • 3
  • 19
  • 10
Loading