Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @RunWith(SpringJUnit4ClassRunner.class)
- @ContextConfiguration(classes = MyRealApplicationConfig.class)
- public final class MyApplicationSpringTest {
- @Inject MyApplication myApplication;
- @Mocked SomeService mockService;
- @BeforeClass // runs before Spring configuration
- public static void setUpMocksForSpringConfiguration() {
- new MockUp<SomeService>() {
- @Mock String getName() { return "one"; }
- };
- }
- @Test
- public void doSomethingUsingMockedService() {
- new Expectations() {{ mockService.doSomething(); result = "two"; }};
- String result = myApplication.doSomething();
- assertEquals("one two", result);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement