diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc index 4904386771..0a4def3ed7 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc @@ -7157,6 +7157,19 @@ NOTE: JSON helper classes can also be used directly in standard unit tests. To d call the `initFields` method of the helper in your `@Before` method if you do not use `@JsonTest`. +If you're using Spring Boot's AssertJ-based helpers to assert on a number value +at a given JSON path, you might not be able to use `isEqualTo` depending on the type. +Instead, you can use AssertJ's `satisfies` to assert that the value matches the given +condition. For instance, the following example asserts that the actual number is a float +value close to `0.15` within an offset of `0.01`. + +[source,java,indent=0] +---- +assertThat(json.write(message)) + .extractingJsonPathNumberValue("@.test.numberValue") + .satisfies((number) -> assertThat(number.floatValue()).isCloseTo(0.15f, within(0.01f))); +---- + [[boot-features-testing-spring-boot-applications-testing-autoconfigured-mvc-tests]]