roadtripryan wrote:
I am trying to test using TestNG/Spring/ and Maven Surefire 2.4.1.
My test suite runs great from within eclipse as individual tests or as a
whole suite. When I try and run the tests in Maven Surefire, however, they
fail. It appears Surefire is not calling the correct @BeforeMethod method.
(When running the whole suite, or an individual test.)
As you might expect, all Surefire does is call TestNG directly; we don't
directly call @BeforeMethod, @Test, etc.
From testing it, it seems Surefire calls the @BeforeMethod in the base
class, but not in extending classes if they override it. I am extending
Springs AbstractTestNGSpringContextTests, and it is calling the base class
methods, not my extending classes @BeforeMethod and @AfterMethod.
Interestingly, it seems to call the correct @BeforeClass method.
If you're having a problem with a TestNG test that you believe should be
working, please file a bug on jira.codehaus.org; please also attach a
minimal Maven project that reproduces the problem. Ideally a test like
this should be nothing more than a pom.xml file and a couple of TestNG
classes in appropriate directories. (Please don't include any spring
classes in this test case unless it's absolutely necessary to do so.)
-Dan