> For the complete documentation index, see [llms.txt](https://jihoony.gitbook.io/developers-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jihoony.gitbook.io/developers-notes/developer/readme/spring/reflectiontestutils.md).

# ReflectionTestUtils

using `ReflectionTestUtils` for inject field in Object

```java
import org.junit.jupitor.api.BeforeEach;
import org.springframework.test.util.ReflectionTestUtils;

class ServiceTest{
    private MyService myService;
    
    @BeforeEach
    void setUp(){
        myService = new MyServiceImpl();
        ReflectionTestUtils.setField(myService, "enable", true);
        ReflectionTestUtils.setField(myService, "url", "https://www.example/com");
    }
}
```

{% embed url="<https://www.baeldung.com/spring-reflection-test-utils>" %}
