title: Spring-boot - Parameterized Test - Access Application.properties in MethodSource
body: <p>When writing a <code>ParameterizedTest</code> with spring-boot, one can specify a <code>MethodSource</code> which provides the values. The <code>MethodSource</code> is a static method, which means accessing autowired values and members is not possible.</p>
  
  <p>I do define a value in the <code>application.properties</code> which is crucial for setting up the parameters(it points to the directory containing the data I need). How can I access the value within the static method?</p>
  
  <p>example code:</p>
  
  <p>application.properties:</p>
  
  <pre><code>com.example.directorypath=a/b/c
  </code></pre>
  
  <p>ApplicationTest:</p>
  
  <pre><code>@ActiveProfiles("dev")
  @RunWith(SpringRunner.class)
  @SpringBootTest
  public class RdxApplicationTests {
  
      @Value("${com.example.directorypath}")
      private String directory;
  
      @ParameterizedTest
      @MethodSource("provideDirectories")
      public void test(File dir){
          System.out.println(dir);
      }
  
      private static Stream&lt;Arguments&gt; provideDirectories(){
          //here is the place I need the value
          File f = new File(directory);
  
          return Arrays.stream(Objects.requireNonNull(f.listFiles())).map(Arguments::of);
  
      }
  }
  </code></pre>