Simon
Simon

Reputation: 3274

How to reuse Spring context when running Ant junit batchtest

I'm in the process of upgrading our application to JUnit4. I've managed to get our test cases up and running using the Spring annotations

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration

We then execute all tests with Ant using

<junit ...>
  <batchtest fork="yes" todir="tmp">
    <fileset dir="${testsrc.dir}">
      <include name="**/Test*.java"/>
    </fileset>
  </batchtest>

However, based on our logfiles it appears that the Spring context is re-created for every single test class. Thus, total execution time is way too high. What is the proper approach to have the Spring context only loaded once?

Thanks Simon Niederberger

Upvotes: 1

Views: 619

Answers (1)

Robert Kornmesser
Robert Kornmesser

Reputation: 309

Maybe it's because of the fork parameter? Seems like ant is creating a fork for each single test. I guess normally springs junit runner tries to reuse the context.

Upvotes: 1

Related Questions