Announcement Announcement Module
No announcement yet.
Problem specifying a test execution listener Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem specifying a test execution listener

    I'm trying to specify a custom test execution listener, and my code looks something like this:

    public class RandomTest
        ApplicationContext ctx;
    However, it appears that the TestExecutionListeners annotation removes all of the default annotations. Thus, by specifying one listener of my own I loose the DependencyInjectionTestExecutionListener that is normally provided. (Therefore, the variable "ctx" is always null.)

    My questions are:
    • Is there a way to add a test execution listener without loosing the ones that are normally provided?
    • Are there any "gotchas" when dealing with the DirtiesContext or Transactional annotations while specifying a custom test execution listener?


  • #2
    Extend one of the spring classes this explicitly registers the listeners again or add them yourself. It is assumed that when you specify the TestExecutionListener yourself that you want to be in full control (this is basically the framework default) and as such it doesn't register the defaults.


    • #3
      This makes sense. When you say "Extend one of the spring classes...", which classes are you referring to?


      • #4
        The spring test classes as documented in the reference guide, for instance AbstractTransactionalJUnit4SpringContextTests.


        • #5
          Ah! I'd forgotten that there were test base classes. Cool. Thanks for your help!