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

IsTestNGTestClass fails to detect test classes with non-public @Test methods #16

Closed
sbrannen opened this issue Sep 21, 2021 · 1 comment
Labels
bug Something isn't working
Milestone

Comments

@sbrannen
Copy link
Member

If a TestNG test class has only non-public @Test methods, an attempt to discover tests for that class will find zero tests when the TestNGTestEngine is discovering tests from classes scanned from the classpath.

Changing at least one of the @Test methods to public allows all tests in the class to be detected.

Thus, org.junit.support.testng.engine.IsTestNGTestClass needs to be revised to use candidateClass.getDeclaredMethods() instead of candidateClass.getMethods(), and it will then also need to manually traverse up the type hierarchy in search of @Test methods.

@sbrannen sbrannen added the bug Something isn't working label Sep 21, 2021
sbrannen added a commit to spring-projects/spring-framework that referenced this issue Sep 21, 2021
This commit makes all test methods in our TestNG test classes public
due to the following bug in the TestNG engine for the JUnit Platform.

junit-team/testng-engine#16

See gh-27407
@sbrannen
Copy link
Member Author

Maybe org.junit.platform.commons.support.AnnotationSupport.findAnnotatedMethods(Class<?>, Class<? extends Annotation>, HierarchyTraversalMode) could be used.

Or does that search algorithm do too much with regard to TestNG's standard algorithm?

@marcphilipp marcphilipp added this to the 1.0.5 milestone Jan 2, 2024
sbrannen added a commit to sbrannen/spring-framework that referenced this issue Jan 2, 2024
Thanks to a bug fix in 1.0.5, test methods in TestNG test classes can
finally be package private as was always the case with TestNG itself.

See junit-team/testng-engine#16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants