Try to use a context like this for your test:
Code:
@Configuration
@Import (MyConfig.class)
public class MyTestConfig {
@Bean
public AuditService auditService() {
return Mockito.mock(AuditService.class);
}
}
This "auditService" bean definition is supposed to overwrite the default one.
Then within your test class:
Code:
class OrderServiceTest {
@Autowired
private AuditService auditServiceMock;
@Autowired
private OrderService s;
@Before
public void setUp() {
Mockito.when(auditServiceMock.doSomething(..)).thenReturn(somethingElse);
}
@Test
public void ordersericeTest() {
s...
}
}
Test class setup depends on which testing framework you're working with.