Uploaded image for project: 'Maven Surefire'
  1. Maven Surefire
  2. SUREFIRE-983

'Running a Single Test' feature does not work as expected (for testng provider)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Not A Problem
    • 2.14, 2.15
    • None
    • TestNG support
    • None
    • Patch

    Description

      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.

      Attachments

        1. patch_fix_afterclass_never_be_called.patch
          2 kB
          Alex Chen
        2. test-run-single-case.zip
          4 kB
          Alex Chen

        Issue Links

          Activity

            People

              tibordigana Tibor Digana
              pdckxd Alex Chen
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: