title: How I can load application.properties into test class for getting the spring.profiles.active value?
body: <p>I'm writing integration test which should works only with the specific profile. The problem is that I should get profile name from spring.profiles.active value in application.properties file. But I always get null due to real value from application.properties.</p>
  
  <p>I've created for main method which explicitly put value into System.properties:</p>
  
  <pre><code>@SpringBootApplication
  public class MyApplication {
      public static void main(String[] args) {
      SpringApplication.run(MyApplication.class, args);
  }
      @Autowired
     public MyApplication(Environment environment) {
        String property = "spring.profiles.active";
        System.getProperties().setProperty(property, environment.getProperty(property));
     }
  </code></pre>
  
  <p>But the value still is null. 
  In the test class I use following annotations:</p>
  
  <pre><code>@RunWith(SpringRunner.class)
  @ContextConfiguration(classes = MyApplication.class)
  @SpringBootTest(classes=MyApplication.class)
  </code></pre>
  
  <p>For loading context from the main class where I manually set the necessary value.
  Also tried use <code>@TestPropertySource("classpath:application.properties")
  </code>But nothing help. And I can't hardcode the value. It's should be get only from application.properties</p>
  
  <p><strong>UPDATE</strong>
  It was my mistake. I've tried getValue from static method :/
  Maybe someone know how I can disable class test by use this value?
  The @IfProfileValue still return null and therefore doesn't fit.</p>
  
  <p><strong>UPDATE</strong>
  I've realized that disabling is useless and better just use appropriate config using @SpringBootTest(classes=AppropriateConfigClass.class)</p>
  
  <p>I'll choose <strong>gargkshitiz</strong> answer as solved, because he was the only one who tried to help.</p>