I'm trying to write a unit test case with mockito and I want to inject a bean with real parameters not mocked ones.
That bean has some string values that read from a .properties file.
@Component
public class SomeParameters {
@Value("${use.queue}")
private String useQueue;
}
@RunWith(MockitoJUnitRunner.class)
public class ServiceTest {
@Mock
private A a;
@Autowired
private SomeParameters someParameters;
@Before
public void init() {
MockitoAnnotations.initMocks(this);
}
@Test
public void testMethod() {
if(someParameters.getUseQueue==true){
//do something
}else{
/bla bla
}
}
my main objective is to run a test case with real scenarios. I don't want to use mock values.
I was able to inject bean with real parameters in this way. But this is the unit test case, not an integration test. So I should not give applicationContext. Can you guide me how can handle this situation?
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:applicationContextTest.xml"})
public class ServiceTest {