Announcement Announcement Module
Collapse
No announcement yet.
Can't setup using AbstractTransactionalDataSourceSpringContextTests Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Can't setup using AbstractTransactionalDataSourceSpringContextTests

    I am using AbstractTransactionalDataSourceSpringContextTests (or a subclass) for most integration tests. However, some test methods need to use @NoTransaction. When this is the case, onSetUpBeforeTransaction() which is where we pull beans which cannot be injected by type from the context, resulting NPEs.

    Since onSetup is made final by AbstractTransactionalDataSourceSpringContextTests there seems to be no pre-test hook to use. This seems like an oversight in the test classes. I would think at least there should be an onSetup* that /always/ gets invoked -- transaction or not.

  • #2
    What about onSetUpBeforeTransaction - the method will be called always. As the test is transactional - a tx will be called always - if you don't want/need transactions then use AbstractDependencyInjectionSpringContextTests.

    Comment


    • #3
      Well, I have a test where some test methods should be run in a transactions and others not (@NotTransactional). Its the non-tx tests which are giving me trouble -- the onSetUpBeforeTransaction is /not/ invoked when @NotTransactional is specified, and there is no other setup hook available for these methods.

      From what I can see, I would need to split the test methods across two tests, one which is AbstractTransactional*Tests and one which is just AbstractDependency*Tests. But it would be nice to mix the methods in the same tests for clarity.

      Comment

      Working...
      X