We used to have a few commands like following:
gradlew test --tests *MyTest
For example the class MyTest is in the package com.test.MyTest
.
When using a Gradle version < 5.0 this worked just fine but after the upgrade to 5.1.1 I get following error:
No tests found for given includes: [*MyTest](--tests filter)
We have already replaced all such occurrences because I think using the full path to a class is much better. But I am wondering why this isn't working anymore.
BTW: I am using TestNG and the mentioned class has at least one public method annotated with @Test
.
It took me a lot of digging around to find the solution, so sharing it here. I solved the No tests found for given includes: [*MyTest](--tests filter)
error by changing the Intellij settings according to https://linked2ev.github.io/devsub/2019/09/30/Intellij-junit4-gradle-issue/
Steps:
Found the problem. It has nothing to do with the gradle upgrade or with TestNG.
Basically someone initialized a global variable in some other class and used an fixed index there i.e.
public class myClass extends Something{
private final String name = names.getNames(0);
...
When we called the gradle task with * it executed that piece of code and in that case it lead to an IndexOutOfBoundsException because the list is empty at that point of time.
Executing following command helped me finding the problem:
gradlew test --tests *MyTest --debug
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With