How to run a specific test in multi hierarchy project

Hi Everyone,

I have a multi hierarchy project. PFB the example structure:

image

I want to run test2b only, using gradle wrapper.

So far I have tried adding filter in test task of sub2 project with includeTestsMatching having value test2b.

I have also tried cli with gradlew :sub2:test --tests test2b.

Both resulted in failure saying no tests found for given include.

Could anyone please point me in the right direction as to what I am doing wrong?

Let me know if I need to provide any more info that could help.

Thanks

If that’s your actual folder structure, hopefully you have overridden the default test folders to what you actually have (src/main/test rather than the default src/test/java).

Beyond that, if you’re matching with the package, you should match on the fully-qualified class. That would be tests2b.* rather than just tests2b.

Hi,

Sorry Looks like I made a mistake creating the example manually. I have updated the folder structure.

Also test2b is not in any package.

Tried running gradlew :sub2:test --tests test2b.* but got the same output: no tests found for given includes.

This one shouldn’t work for your updated example. It was for the original post that looked like you had a package called test2b, not class called test2b in the default package.

However, it’s hard to say what’s not quite right in your project. This works as expected using just the details provided. You probably need to provide a small example project where you can reproduce the problem to get any more assistance. It’s likely a small detail in your project that you wouldn’t necessarily know to call out and we wouldn’t necessarily know to mention unless we saw it.