mardi 28 juillet 2020

Gradle: How can I run a specific (architecture) test for each subproject?

I have a Gradle monolith project with around 50 subprojects. I'd like to ensure that the code in each subproject conforms to a specific rule, for example that each class named *Foo is annoted with Bar.

I already wrote a test that successfully scans the classpath and asserts the property I'm interested in.

Where do I put this code so that it is executed for the whole project, either individually for each subproject, or once for the whole codebase?

I know about test fixtures, so I could easily provide the logic in a class that is accessible by all subprojects. However, I'd still need to write a test class that runs the shared code, which I'd have to do for each of my subprojects.

How can I avoid this duplication? I'm looking for something like this:

subprojects {
    additionalTestsFrom project(':architecture-tests')
}

Aucun commentaire:

Enregistrer un commentaire