0

This is a follow up question to this:

TestNG: Identifying which tests methods are next

I realize now that it's possible to intercept test methods. However, it seems that the best time to safely clear the entityManager is before a @DataProvider method is executed.

Is this possible?

Community
  • 1
  • 1
Jan Julian
  • 473
  • 2
  • 4
  • 15

1 Answers1

0

How about a @BeforeMethod?

I like butter (added because SO will not let me submit an answer that's too short)

Cedric Beust
  • 15,480
  • 2
  • 55
  • 55
  • Tried that too. It seems the order of execution goes: check attributes in method annotated with @Test -> @DataProvider -> @BeforeMethod -> @Test (an instance of the method) -> @AfterMethod. If I clear the EM in @BeforeMethod, the entities from the dataProvider would be detached before even reaching the test. I also tried implementing IInvokedMethodListener. However that still happens AFTER the dataProvider and just before the test method is run. – Jan Julian Jan 20 '11 at 01:01
  • I just got to download and read the source code of 5.14.1 and it very much seems that the invocation of the @DataProviders is pretty much hard coded *sad face. Anyway, I suppose I'll just leave that as a feature request for the next version! Thanks for helping out! – Jan Julian Jan 20 '11 at 02:55