Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[java] TestClassWithoutTestCases - false-positive for test classes extending a class with tests (in nested classes) #5011

Open
Wolf2323 opened this issue May 13, 2024 · 0 comments
Labels
a:false-positive PMD flags a piece of code that is not problematic

Comments

@Wolf2323
Copy link

Wolf2323 commented May 13, 2024

Affects PMD Version: 7.1.0

Rule: TestClassWithoutTestCases

Description:
In PMD 6 this was no issue, now in PMD 7 a nested test class is now detected as TestClassWithoutTestCases. I guess previously the class was not detected as test class at all. Now it is detected, and yes it actually has no tests, but they are on the super class.

Code Sample demonstrating the issue:

public class SpeedProfilerTests extends TimeProfilerTests {
	@Nested
	class operations extends TimeProfilerTests.operations {
		@Override
		protected TimeProfiler makeProfiler() {
			return new SpeedProfiler("foo");
		}
	}

Expected outcome:
No violations, as the super class actually has test cases

[INFO] PMD Failure: works.reload.recore.util.operations:22 Rule:TestClassWithoutTestCases Priority:3 The class 'operations' might be a test class, but it contains no test cases..

Running PMD through: Maven

@Wolf2323 Wolf2323 added the a:false-positive PMD flags a piece of code that is not problematic label May 13, 2024
@jsotuyod jsotuyod changed the title TestClassWithoutTestCases - false-positive for test classes extending a class with tests (in nested classes) [java] TestClassWithoutTestCases - false-positive for test classes extending a class with tests (in nested classes) May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:false-positive PMD flags a piece of code that is not problematic
Projects
None yet
Development

No branches or pull requests

1 participant