@@ -86,6 +86,20 @@ a Java properties file:
8686* `key:value`
8787* `key value`
8888
89+ [TIP]
90+ ====
91+ Although properties can be defined using any of the above syntax variants and any number
92+ of spaces between the key and the value, it is recommended that you use one syntax
93+ variant and consistent spacing within your test suite — for example, consider always
94+ using `key = value` instead of `key= value`, `key=value`, etc. Similarly, if you define
95+ inlined properties using text blocks you should consistently use text blocks for inlined
96+ properties throughout your test suite.
97+
98+ The reason is that the exact strings you provide will be used to determine the key for
99+ the context cache. Consequently, to benefit from the context cache you must ensure that
100+ you define inlined properties consistently.
101+ ====
102+
89103The following example sets two inlined properties:
90104
91105[tabs]
@@ -95,24 +109,61 @@ Java::
95109[source,java,indent=0,subs="verbatim,quotes",role="primary"]
96110----
97111 @ContextConfiguration
98- @TestPropertySource(properties = {"timezone = GMT", "port: 4242"}) // <1>
112+ @TestPropertySource(properties = {"timezone = GMT", "port = 4242"}) // <1>
113+ class MyIntegrationTests {
114+ // class body...
115+ }
116+ ----
117+ <1> Setting two properties via an array of strings.
118+
119+ Kotlin::
120+ +
121+ [source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
122+ ----
123+ @ContextConfiguration
124+ @TestPropertySource(properties = ["timezone = GMT", "port = 4242"]) // <1>
125+ class MyIntegrationTests {
126+ // class body...
127+ }
128+ ----
129+ <1> Setting two properties via an array of strings.
130+ ======
131+
132+ As of Spring Framework 6.1, you can use _text blocks_ to define multiple inlined
133+ properties in a single `String`. The following example sets two inlined properties using
134+ a text block:
135+
136+ [tabs]
137+ ======
138+ Java::
139+ +
140+ [source,java,indent=0,subs="verbatim,quotes",role="primary"]
141+ ----
142+ @ContextConfiguration
143+ @TestPropertySource(properties = """
144+ timezone = GMT
145+ port = 4242
146+ """) // <1>
99147 class MyIntegrationTests {
100148 // class body...
101149 }
102150----
103- <1> Setting two properties by using two variations of the key-value syntax .
151+ <1> Setting two properties via a text block .
104152
105153Kotlin::
106154+
107155[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
108156----
109157 @ContextConfiguration
110- @TestPropertySource(properties = ["timezone = GMT", "port: 4242"]) // <1>
158+ @TestPropertySource(properties = ["""
159+ timezone = GMT
160+ port = 4242
161+ """]) // <1>
111162 class MyIntegrationTests {
112163 // class body...
113164 }
114165----
115- <1> Setting two properties by using two variations of the key-value syntax .
166+ <1> Setting two properties via a text block .
116167======
117168
118169[NOTE]
@@ -172,7 +223,7 @@ Java::
172223 @ContextConfiguration
173224 @TestPropertySource(
174225 locations = "/test.properties",
175- properties = {"timezone = GMT", "port: 4242"}
226+ properties = {"timezone = GMT", "port = 4242"}
176227 )
177228 class MyIntegrationTests {
178229 // class body...
@@ -185,7 +236,7 @@ Kotlin::
185236----
186237 @ContextConfiguration
187238 @TestPropertySource("/test.properties",
188- properties = ["timezone = GMT", "port: 4242"]
239+ properties = ["timezone = GMT", "port = 4242"]
189240 )
190241 class MyIntegrationTests {
191242 // class body...
0 commit comments