简体   繁体   中英

Maven, testng, surefire: not running AfterClass

Is there a reason why maven would not run my AfterClass which is set to alwaysRun=true? BeforeClass is run without issues and test passes according to surefire report. I run command in terminal:

mvn -Dtest=TestSuite2#test_case3 test

and get

Results :

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1:10.228s
[INFO] Finished at: Wed Nov 13 18:24:07 EET 2013
[INFO] Final Memory: 14M/114M
[INFO] ------------------------------------------------------------------------

The problem is though that my AfterClass, where I quit driver (driver.quit()) is not run. Everything works as expected, if I run the same test via Eclipse with TestNG (right click on the method, run as TestNG test)

It works in IDE (Eclipse/IDEA) because it creates testng.xml and run test against it. You need to check pom.xml and revise your Maven Surefire Plugin configuration.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM