title: How do I Mock SpringApplication.run
body: <p>I have a File handler for Spring Batch that I want to test.</p>
  
  <p><code>SpringApplication.run()</code> is a static method for which I would like to verify the arguments passed to it.  </p>
  
  <p>Does this mean I need to go down the PowerMock path or is there something in the SpringFramework that will enable me to test this?</p>
  
  <pre><code>public File handleFile(File file) {
  
      // Start the Batch Process and set the inputFile parameter
      String[] args = {"--inputFile=" + file.getAbsolutePath()};
      SpringApplication.run(InitialFileBatchApplication.class, args);
  
      return null;
  }
  </code></pre>
  
  <p>My test class has the following annotations which don't seem to be working:  </p>
  
  <pre><code>@RunWith(PowerMockRunner.class)
  @PowerMockRunnerDelegate(SpringJUnit4ClassRunner.class)
  @SpringBootTest
  @PrepareForTest(SpringApplication.class)
  </code></pre>
  
  <p>What am I missing?</p>
  
  <p>The exception getting thrown is:</p>
  
  <blockquote>
    <p>java.lang.IllegalStateException: Failed to transform class with name org.springframework.boot.SpringApplication. Reason: cannot find
    org.springframework.web.context.support.StandardServletEnvironment</p>
  </blockquote>
  
  <p>This occurs when the <code>@PrepareForTest(SpringApplication.class)</code> is processed. I'm testing a Spring Batch application so there is no web environment and I've also added.</p>
  
  <pre><code>@SpringBootTest(webEnvironment=WebEnvironment.NONE)
  </code></pre>