It would be helpful if we could offer something similar to ApplicationContextRunner but for SpringApplication integration tests. See this Twitter thread for background.

Comment From: johnrengelman

This convo came from me trying to written reusable acceptance tests for a platform integration library. The existing annotation based framework makes it impossible for the test configuration to be contained within the test method setup and also makes it very difficult to control order of the test setup.

The ApplicationContextRunner seems like a very good fit. It would be nice of instead of container the test expectations with the run(ContextConsumer) method to have another method (eg start()) that returns the control object (eg AssertableApplicationContext that implements AutoCloseable. This way, I could write something like this in Spock:

class AppSpec extends Specification {

  @AutoCleanup
  AssertableApplicationContext ctx = new ApplicationContextRunner().withApplication(TestApplication).withPropertyValues("app.enabled=false").start()

  def "run some test"() {
    expect:
    ctx.containsBean("someBeanName")
  }
}

Comment From: snicoll

We've discussed this one today and a SpringApplicationRunner that would provide a similar experience to what ApplicationContextRunner does for the raw context sounds quite nice. From a glance, it is a completely separate API but we feel it is worth it and would reduce the confusion of trying to make this request fit in the current ApplicationContextRunner.

Comment From: wilkinsona

22405 is of interest here as well.