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
Groovy 3 Unit Test Class: TestNGException at Parameters.java:437 #2360
Comments
Found a workaround by filtering:
plugins { groovy } repositories { jcenter() } dependencies { implementation("org.codehaus.groovy:groovy-all:3.0.5") testImplementation("org.testng:testng:7.3.0") } tasks.test { useTestNG() filter { excludeTestsMatching("*.setMetaClass") excludeTestsMatching("*.setProperty") } } |
|
@ctzen - Can you please help me understand what is expected from TestNG in this case ? I am not that familiar with Groovy. |
I believe the Groovy project people can explain it better than me, perhaps you can ask in that JIRA. However, this is my understanding of the issue. Groovy augment groovy classes with internal methods when converting them to Java classes. Before Groovy 3, these internal methods were marked as synthetic, which TestNG would ignore when discovering test methods. (I traced the TestNG method discovery to AnnotationHelper.findMethodsWithAnnotation()) Since Groovy 3, these internal methods are no longer marked as synthetic, and TestNG will pick them up as test methods. The fix is for TestNG to NOT pick these Groovy internal methods up as test methods. The straight forward way is of course to ignored methods annotated with @groovy.transform.Internal. Another possible way is to enhance the TestNG test method discovery. The 2 erroneous methods both have parameters but no DataProvider. If TestNG is to ignore methods with parameters but no DataProvider, that should also solve this issue. May be we can ask the JACOCO project how they did it? |
@krmahadevan We already have some Groovy tests. Do. you reproduce the issue? |
@juherr - we dont have any tests breaking as part of our build. I think the problem comes only when we move to groovy 3. |
For the record, some related Jacoco issues: jacoco/jacoco#610 jacoco/jacoco#733 |
… annotated with @groovy.transform.Internal
…ere detected as test methods
#2360: fix bug where Groovy 3 internal generated methods were detected as test methods
TestNG Version
7.3.0
Expected behavior
Test pass without exception
Actual behavior
Gradle suite > Gradle test > foo.FooTest > setMetaClass FAILED
org.testng.TestNGException at Parameters.java:437
Received a failure event for test with unknown id '55.7'. Registered test ids: '[55.3, 55.2, 55.1, :test]'
Is the issue reproductible on runner?
Test case sample
Java version AdoptOpenJDK (build 25.262-b10, mixed mode)
Gradle version 6.6.1
Groovy version 3.0.5
Project attached: g3tng.tar.gz
src/test/groovy/foo/FooTest.groovy
build.gradle.kts
Observations:
No issue with groovy version 2.x
TestNG selects
setMetaClass
andsetProperty
as test methods.When runs with ReportNG:
The text was updated successfully, but these errors were encountered: