1

I use DBUnit, Spring Test, TestNG and maven(come with Surefire) to run the test. But when some assertions of DBUnit failed. They do not specify which test method of mine is failed but the test method of AbstractTestNGSpringContextTests.springTestContextAfterTestMethod.

Could you guys help me to isolate the failure. I need the know the root the the failure. Thanks,

Esca Tran
  • 129
  • 1
  • 3
  • 14

1 Answers1

0

If a failure occurs in AbstractTestNGSpringContextTests.springTestContextAfterTestMethod(), that means that the failure occurred in an afterTestMethod() method within a configured TestExecutionListener.

If you're using DbUnit via a custom TestExecutionListener, then you likely need to check the stack trace or the log to see what happened.

Setting the log level to DEBUG for org.springframework.test.context should shed some light on the story. For example, at DEBUG log level, you should see quite a bit of log messages that include the TestContext, and for each one you will see the testClass and testMethod properties. That will let you know which method was executing when the error occurs.

Regards,

Sam (author of the Spring TestContext Framework)

Sam Brannen
  • 29,611
  • 5
  • 104
  • 136
  • Hi, I add the logger setting for org.springframework.test.context but it does not work. Even the logger setting for org.dbunit.assertion. There is only the Test class's name show up. Nothing more. springTestContextAfterTestMethod(com.bac.web.UIControllerImplTest) – Esca Tran Jul 19 '14 at 15:41
  • Debug logging against `org.springframework.test.context` most definitely works. Thus, you must have incorrectly set up logging. The easiest to get logging working in tests is to add Log4j to your classpath and configure either `log4j.properties` or `log4j.xml` in the root of the classpath -- for example in `src/test/resources`. – Sam Brannen Jul 20 '14 at 10:53
  • Thank you Brannen. I test if log4j get the setting from my file log4j.xml. I'm sure that the log4j.xml file work correctly. I did try to make it invalid, and log4j complained immediately. I also try to change the log level of some package, and that effects. – Esca Tran Jul 21 '14 at 05:04
  • I'm afraid we likely can't help you much more without seeing your project. Could you therefore create an [issue project](https://github.com/SpringSource/spring-framework-issues#readme) that reproduces the problem in the simplest fashion? – Sam Brannen Jul 21 '14 at 12:19