-
Notifications
You must be signed in to change notification settings - Fork 40.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spring Boot Starter Test includes dependencies with split packages which causes compilation failures when testing using the module path #15967
Comments
Thanks for the sample. The problem is that there are two split packages in the dependencies of
In short, In Hamcrest 2.1, the Regardless of the above, please note that classpath scanning does not work for module path-based testing: spring-projects/spring-framework#21515. As such, it's hard to justify making changes to the test starter to accommodate module path-based testing and I would recommend using the class path instead. |
Thanks for the link to the module path-based testing issue. Do you think that the Spring Initializr should generate a sample project with Java modules and maven/gradle scripts that work including tests (using classpath)? I could create an issue for this there. |
@rajeshja Spring Initializr is not meant to generate sample projects, in the sense of showing how to do something. A guide is usually what we aim for though I am not sure one on the modules path would be accepted. |
We've discussed this and agreed that we don't want to make any changes to the starter. @rajeshja You may want to raise an issue against |
Five years on it appears unlikely that the practically dead-in-the-water + <json-unit.version>3.2.7</json-unit.version>
@@ ... @@
+ <dependency>
+ <groupId>net.javacrumbs.json-unit</groupId>
+ <artifactId>json-unit-spring</artifactId>
+ <version>${json-unit.version}</version>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.skyscreamer</groupId>
+ <artifactId>jsonassert</artifactId>
+ </exclusion>
+ </exclusions>
</dependency> +import static net.javacrumbs.jsonunit.spring.JsonUnitResultMatchers.json;
@@ ... @@
final var requestJson = get("/foo").contentType(MediaType.APPLICATION_JSON);
- final var matchingJsonBody = content().json(read("/foo.json"));
+ final var matchingJsonBody = json().when(Option.IGNORING_EXTRA_FIELDS).isEqualTo(read("/foo.json")); It seems likely that The |
@commonquail I think we'll need to take the lead from Spring Framework here. MockMVC also uses jsonassert. I've opened spring-projects/spring-framework#32791 for that team to consider. |
Thanks to @philwebb, we have a @commonquail for the above a |
That's a superior core API, to be sure, but just for the record that's not very useful to somebody that wanders down this path. JSONassert is still broken and still bundled with Spring so we still have to manually exclude it and supply a work-around, and calling e.g. JsonUnit through a bespoke var matchingJsonBody = content().json(read("/foo.json"), (expectedJson, actualJson) -> {
JsonAssertions.assertThatJson(actualJson).when(Option.IGNORING_EXTRA_FIELDS).isEqualTo(expectedJson);
return JsonComparison.match();
}); In any case, I've filed lukas-krecan/JsonUnit#767, too. It's unfortunate that JSONassert remains the only option available to the Spring project. |
FWIW, that comment is a bit rude IMO. The API just got introduced so any follow-up that may happen in other projects still need to happen.
That's inaccurate. |
I'm sorry to appear rude. It seems to me you have misunderstood the crux of the matter, however: there is no follow-up that needs to happen elsewhere because there is no follow-up anywhere else that matters; JSONassert does not compile on the module path, so
Not according to spring-projects/spring-framework#32791 (comment) nor to my own investigation. |
I think it's going to take us some time to provide a complete solution and we can't even begin until we have the groundwork that spring-projects/spring-framework#32791 provides. We could consider removing It might be helpful if JsonUnit separated their Spring module from the core release. That way we could depend on it without a cycle. It's quite a shame that https://github.com/skyscreamer/JSONassert isn't getting any updates these days. |
I'm using Gradle 5.2 on Java 11.0.1 with a very simple project that adds a controller and an entity package to the base starter created with Spring 2.1.2. The code in
src/main/java
is setup as a Java module. He is my module definition (I only have one at this time)Running
gradlew build
breaks atcompileTestJava
with 100 errors of the form:Replacing the
org.springframework.boot:spring-boot-starter-test
dependencies with individual imports of the following works. Importing the failing code into Intellij IDEA and running the SpringBootApplication in the IDE also works.A sample project to replicate the issue is at:
https://github.com/rajeshja/springboot2.1-java11-gradle-bug
The text was updated successfully, but these errors were encountered: