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.
Related
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)
I have a project with a deep maven structure and am evaluating switching from Eclipse to IntelliJ.
I've imported the top-level pom.xml. I know that I can:
Build the whole project with maven goals (I use 'test-compile' to build the test classes)
Run the tests from the IntelliJ test runner. This seems to find the classes/test-classes from the target folder of the project.
However, I would like to just change a test or the code under test, save it, and rerun it without having to manually run the maven test-compile again (like I could with Eclipse). Is this possible with IntelliJ?
I think the issue is that the IntelliJ 'Build Project' action does not build the test classes (and other classes) into the target folder that the test runner looks in.
If you import a Maven project in IntelliJ IDEA, you will be able to build and run the tests from the IDE instead of Maven which is a lot faster because of the incremental compilation.
Make sure this option is disabled and use JUnit Run/Debug configuration, don't run the maven goals.
Thanks to the suggestion from #CrazyCoder, I was able to get this working by following these steps, as I think the issue was Eclipse artifacts fighting with IntelliJ artifacts:
Remove all .classpath, .project and .iml files from the entire code tree
Remove .idea from the root - we need to start again
Open the top-level pom.xml in IntelliJ
If needed, perform a mvn compile (needed for me due to some generated sources)
Rebuild your project
After this, don't open your project in Eclipse again!
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?
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.
Hi) when I compile the project are with gradle idea, I should get jar file...?
maybe in the folder dist...
The problem is that I get only two files start.sh and start.cmd
gradle idea doesn't compile the project. It creates project files (*.iws, *.ipr, *l.iml) for IDEA (the IDE from JetBrains). Likewise, there is gradle eclipse to create project files for the Eclipse IDE.
To create a Jar, you can do gradle jar or gradle build (assuming you have the java plugin applied). gradle tasks shows which tasks are available for a given project.
start.sh and start.cmd sound like they are coming from the application plugin. Are you using the application plugin?
The above poster is right that gradle idea simply creates the IntelliJ files that define your modules, src locations, etc. It does NOT compile the project.
Adding apply plugin: 'java' to your build.gradle will allow you to run gradle jar to generate a jar file.