Inject private field from unit test

public class DeeplinkService { 

@Value("${deeplink}")

 private String deeplink;

}


class DeeplinkServiceTest {

@InjectMocks

private DeeplinkService deeplinkService;


@BeforeEach 

public void setup() {

{ ReflectionTestUtils.setField( deeplinkService, "deeplink", TestConstants.TEST_DEEPLINK ); }

}


It is possible to inject private field from unit test with Reflection

Comments

Popular posts from this blog

Installation instructions for some programs on linux ubuntu

Hibernate and Application Performance

timezone ile bagli Jackson deserializableda problem