rule_key=pmd-unit-tests%3AJUnit4TestShouldUseAfterAnnotation applies to testng test

Template for a good bug report, formatted with Markdown:
*Community EditionVersion 7.9.4 (build 35981) Plugins latest from October 2020

We have the following test:

import java.io.File;
import java.util.concurrent.TimeUnit;

import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

public class JavaFlightRecorderServiceTest {



    @AfterClass
    public void tearDown() throws Exception {
        service.stop();
        TimeUnit.SECONDS.sleep(2);
        File file = new File(config.getOutputFile());
        System.out.println("File" + file.getAbsolutePath());
        assertTrue(file.exists());
        assertTrue(file.delete());
    }


}

We get the following message from Sonar:

MAJOR SonarQube violation:


JUnit 4 tests that clean up tests should use the @After annotation, JUnit5 tests should use @AfterEach or @AfterAll


Read more: https://sonarqube.lmera.ericsson.se/coding_rules#rule_key=pmd-unit-tests%3AJUnit4TestShouldUseAfterAnnotation

It does not seem relevant since it is a testng test. Has this been fixed?

br.

//mikael

Hello @eraonel,

PMD plugin is a community plugin, not maintained by SonarSource anymore. I believe the best thing to do to reach the right people is to directly report this issue on the Github repository of the plugin.

Best,
Quentin