-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Forbid usage of static inner test classes in TestNG #11316
Forbid usage of static inner test classes in TestNG #11316
Conversation
56cca63
to
d2985c6
Compare
} | ||
|
||
@VisibleForTesting | ||
public static Optional<Class<?>> performActionIfInnerClass(Class<?> testClass, Consumer<Class<?>> consumer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static boolean isInnerClass(Class<?> testClas)
* Detects test classes which are defined as static inner classes | ||
* TestNG support is poor for these static inner test classes: https://github.com/trinodb/trino/pull/11185 | ||
*/ | ||
public class ReportStaticInnerTestClasses |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove "Static", it doesn't matter.
@Test | ||
public void testInvalid() | ||
{ | ||
assertThat(getEnclosingClass(TestClassWithInnerTestClasses.TestInnerTestClass.class)) | ||
.isPresent() | ||
.contains(TestClassWithInnerTestClasses.class); | ||
|
||
assertThat(getEnclosingClass(TestClassWithMultipleInnerTestClasses.TestInnerTestClassOne.class)) | ||
.isPresent() | ||
.contains(TestClassWithMultipleInnerTestClasses.class); | ||
|
||
assertThat(getEnclosingClass(TestClassWithMultipleInnerTestClasses.TestInnerTestClassTwo.class)) | ||
.isPresent() | ||
.contains(TestClassWithMultipleInnerTestClasses.class); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tested method is one-liner "is inner class". I don't think this test adds any value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to prove to myself the automation works, I can remove the MultipleInnerTestClasses
cases but I think keeping at least the first testcase is helpful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if/once you apply https://github.com/trinodb/trino/pull/11316/files#r819513710, there is nothing this test actually tests.
d2985c6
to
d0630d1
Compare
aa8893c
to
689bdb5
Compare
TestNG support for inner test classes is poor, see this issue: trinodb#11185
689bdb5
to
1dc1814
Compare
Description
TestNG support for static inner test classes is poor
Adds a TestNG listener to fail if a test class is defined as a static inner class
Related issues, pull requests, and links
This PR introduced usage of static inner test classes in kudu:
#10940
This PR subsequently removed the static inner test classes after some tests were not being run:
#11185
Documentation
(X) No documentation is needed.
( ) Sufficient documentation is included in this PR.
( ) Documentation PR is available with #prnumber.
( ) Documentation issue #issuenumber is filed, and can be handled later.
Release notes
(X) No release notes entries required.
( ) Release notes entries required with the following suggested text: