spring-projects / spring-projects/spring-boot
Support method injection of JSON testers
Open
@snicoll is already working on this.
Since Mar 25, 2026.
status: pending-design-work
type: enhancement
- Dominant language
- Java
- Stars
- 81.5k
- Forks
- 42.7k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 65
Description
Something like this:
@JdbcTest
@AutoConfigureJsonTesters
class SampleTests {
@Test
void sampleTest(@Autowired BasicJsonTester jsonTester) {
assertThat(jsonTester.from("{}")).hasJsonPath("$");
}
}
Fails with:
Uninitialized BasicJsonTester
java.lang.IllegalStateException: Uninitialized BasicJsonTester
at org.springframework.util.Assert.state(Assert.java:80)
at org.springframework.boot.test.json.BasicJsonTester.verify(BasicJsonTester.java:166)
at org.springframework.boot.test.json.BasicJsonTester.from(BasicJsonTester.java:110)
at com.example.SampleTests.sampleTest(SampleTests.java:17)
Looking at JsonTestersAutoConfiguration and JsonMarshalTestersBeanPostProcessor, only fields are considered for tester initialization:
This prevents consistent code style in codebases where method injection is preferred.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.