Why can't we fetch @Value during JUnit execution and how to set the @Value during JUnit execution in Spring boot

Viewed 19

How to fetch @Value during JUnit execution

Example:

public class Test {

   @Value("${value}")
   private String value;

}
1 Answers

@Value is a feature of Springboot.

These are your options:

  1. Let your test cases run as @SpringBootTests.
  2. Find ways to set these configuration values yourself (e.g. make them public or package private or add setters for them).
Related