Gradle multi-module project does not run tests in one of the modules - gradle

We have a Gradle 5.x multi-module project consisting of four modules written in Java and a plugin written in groovy. When the modules were in separate git repos, we had coverage for the plugin because the tests ran. With everything in one repo, it now no longer runs the groovy tests, yet it runs all of the Java tests. We've tried setting the classes directories explicitly in test {
jacoco {
includes = [dirs here...]
but it has no effect. There doesn't seem to be anything online about this problem. Has anyone seen it? If so, what's the fix?

Related

ArchUnit: How to get gradle to execute the tests?

I have a gradle project where I've added the archunit-junit5 dependency and written some test classes with #ArchTests. These get picked up by IntelliJ.
How do I get gradle to execute them?
I've found the com.societegenerale.commons:arch-unit-gradle-plugin but that seems to need configuration in the gradle file.
I just want gradle to pick up the tests I already have in the test/java directory.
Gradle should pick up #ArchTests with archunit-junit5 if you useJUnitPlatform().
https://github.com/TNG/ArchUnit-Examples/tree/main/example-junit5 shows a quite minimal working example.

How to execute all test case in the “spring-boot” project with gradle?

spring-boot migrated from maven to gradle since 2.3.0.M1, so the question is tagged with gradle. link
What I want to do?
We known, spring-boot-dependencies project is managing lots of jar's version and works well, that's so great! We plan to use spring-boot-dependencies as a basic to manage jar's version in my company. sometimes we need to upgrade some of the jar in spring-boot-dependencies because of vulnerabilities, and this may cause version mismatch between jars.
I have noticed that, there is about 10*000 tests case in springboot project:
So I'd like to modify some jar's version in the spring-boot-dependencies project, and then run all test of spring-boot projects, to help me analyse is there any version mismatch。
What I did?
clone the latest code from github:https://github.com/spring-projects/spring-boot.git
run .\gradlew.bat build(work on windows) in the spring-boot project root directory.
it seems only a few tests get executed:
So, my question is how can I execute all test case in spring-boot project?
Any suggestions would be greatly appreciated!
the path buildSrc/ is for the gradle custom plugin code. You are therefore looking at the build tool test results.
your main code results will be under build/reports/... folder (of each module)

Importing tests from another project using Gradle

I have a microservice that has a sub-folder full of integration tests written in Groovy. These tests basically make a bunch of REST calls. Gradle is configured to produce a JAR for these tests like so:
//Explicitly add the integration tests to the JAR
jar {
from sourceSets.test.output
}
Unzipping the JAR shows the Groovy tests that were in the project. That seems good so far.
Now, there is a larger project that I want to use (in a different git repo) that will import these tests and run them. The plan is to import several other test suites in a similar fashion and build a sort of uber-test project. This project can import the test JAR as a dependency as testCompile. I can see the JAR in the SourceSets using IDEA's gradle plugin. However, I can't get the tests to run using gradle test.
How can I modify the uber-test project to execute these imported test?

Why does gradle not find the resources?

I'm currently trying to migrate a project from Gradle 3.5 to the latest Gradle version 4.9. and I'm running into the problem, that Gradle doesn't find the resources that it needs to execute the junit tests. These resources are generated upfront and contain some configuration files and referential data.
The project uses a combination of npm and Gradle to compile. Usually we run a npm script which executes a couple of tasks sequentially using run-s, e.g. webpack builds to generate some static resources. At the end we compile everything together using Gradle. The last Gradle task also executes the junit tests. This step fails and makes the whole build fail. The Gradle runner complains that some resources are not found, although the get properly copied to the right places.
When I execute ./gradlew test --rerun-tasks (Yes, we use the wrapper, which has been properly upgraded, too) right after the last Gradle build step failed, it executed the junit tests successfully.
I know, that the directory structure changed in Gradle 4.x, but this doesn't seem to be the problem.
My suspicion is, that it has something to do with how we normally run the whole build process. Something in the combination with npm.

sonar-maven-plugin with multi-module maven

I have a multi-module maven project which seems to have correctly generated OWASP dependency reports at both the parent and child module /target dirs using the org.owasp:dependency-check-maven plugin as so:
However, referencing the plugin docs, and executing the sonar-maven-plugin as below, I just can't work out what the correct command should be, any combination seems to lead to a build failure:
mvn sonar:sonar -Dsonar.sources=? -Dsonar.dependencyCheck.reportPath=?
Can anyone explain how to configure a multi-module maven project and have Sonar recognise the OWASP dependency reports?
Below is a screenshot of the starting point - we've had a CI pipeline up and running producing separate unit and integration test coverage stats for each of the submodules for some time.
Ok, so have contacted the author and the dependency-check-sonar-plugin doesn't work with a multi-module maven project.
So we are just going to produce a static artefact in a one-off fashion and not attempt to integrate with our CI pipeline.

Resources