[
https://issues.apache.org/jira/browse/SUREFIRE-983?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14953304#comment-14953304
]
Tibor Digana commented on SUREFIRE-983:
---------------------------------------
Extract the project in zip.
Replace @AfterClass with @AfterTest(alwaysRun = true) where the cleanUp()
method runs just once (TestNG 5.10 or 6.9.6).
If you use @AfterTest(alwaysRun = true) and TestNG 5.10 the method is called
twice but we have three test methods. With 6.9.6 just once.
> 'Running a Single Test' feature does not work as expected (for testng
> provider)
> -------------------------------------------------------------------------------
>
> Key: SUREFIRE-983
> URL: https://issues.apache.org/jira/browse/SUREFIRE-983
> Project: Maven Surefire
> Issue Type: Bug
> Components: TestNG support
> Affects Versions: 2.14, 2.15
> Environment: Apache Maven 3.0.4 (r1232337; 2012-01-17 16:44:56+0800)
> Maven home: D:\Maven\apache-maven-3.0.4
> Java version: 1.6.0_26, vendor: Sun Microsystems Inc.
> Java home: C:\Program Files\Java\jdk1.6.0_26\jre
> Default locale: en_US, platform encoding: Cp1252
> OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
> Reporter: Alex Chen
> Attachments: patch_fix_afterclass_never_be_called.patch,
> test-run-single-case.zip
>
>
> Method with @AfterTest annotation are never been called if use the 'Running a
> Single Test' feature for testng.
> There are two classes in test project.
> BaseTest # only has one method cleanUp with @AfterTest. it just prints out
> a string 'clean up'
> MyTest # inherit from BaseTest (cases: testPlus, testSubtract,
> testMultiplication)
> 1).Cmd: mvn test
> Result:
> -------------------------------------------------------
> T E S T S
> -------------------------------------------------------
> Running TestSuite
> Configuring TestNG with: TestNG652Configurator
> clean up <==================================== Right @AfterClass method
> outputs
> Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.322 sec
> Results :
> Tests run: 3, Failures: 0, Errors: 0, Skipped: 0
> [INFO]
> ------------------------------------------------------------------------
> [INFO] BUILD SUCCESS
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Total time: 1.662s
> [INFO] Finished at: Sun Apr 07 20:21:41 CST 2013
> [INFO] Final Memory: 7M/244M
> [INFO]
> ------------------------------------------------------------------------
> 2).Cmd: mvn test -Dtest=MyTest#testPlus
> Result:
> -------------------------------------------------------
> T E S T S
> -------------------------------------------------------
> Running MyTest
> Configuring TestNG with: TestNG652Configurator
> <==================================== where is 'clean up'
> Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.292 sec
> Results :
> Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
> [INFO]
> ------------------------------------------------------------------------
> [INFO] BUILD SUCCESS
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Total time: 1.641s
> [INFO] Finished at: Sun Apr 07 20:25:22 CST 2013
> [INFO] Final Memory: 7M/244M
> [INFO]
> ------------------------------------------------------------------------
> I find a workaround to resolve this problem. Please see the attachment.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)