I have never did anything in the buildSrc directory
That’s probably some example you copied, or default the init
plugin generated or similar.
But by not removing it, you configured it like that.
but have this line in my build.gradle.kts file:
testImplementation(“junit:junit:4.13”)
Which just is a library you add to your test compile classpath.
But by having useJUnitPlatform()
, you tell Gradle “I have JUnit Platform tests, so use JUnit Platform to run them”, which then does not find any tests, as you only coded JUnit 4 tests and did not include the vintage engine that would run on the JUnit Platform and run the JUnit 4 tests, as described above.
I want to keep my JUnit 4 tests. at least for now, as I made them as JUnit 4 was the cutting edge version. Having both versions would be nice for new unit tests, but for now I want to get the old tests running again.
I told you both ways above, either use useJUnit()
to only use JUnit 4, or add the vintage engine as runtimeOnly
dependency, so that your JUnit 4 tests run through the JUnit Platform.
What should I do with the buildSrc stuff…as far I know from trying, it is a bad idea to delete it
Well, you use it, so it is a bad idea to delete it.
Don’t use it, then you can also delete it.
Or use it properly.
even I’m sure that Gradle made it up by itself.
Gradle does not make up anything, it just does what you tell it to.
You most probably used the init
task and when it asked you, said that you do want to use “multiple subprojects” which you actually do not want, you only have one subproject per build you have, so it does imho not make too much sense. But by answering like that, it also generated the buildSrc
with convention plugins where you configure your conventions “how does a java project in this build look like” and similar things and then apply just that convention plugin to all the subprojects (the one you have in your case).
You can read more about convention plugins like these at Sharing Build Logic between Subprojects and about precompiled script plugins as which they are implemented in your case at Developing Custom Gradle Plugins.
What is this?
It is what makes testing fun again.
https://spockframework.org/spock/docs/2.3/all_in_one.html