File tree Expand file tree Collapse file tree 2 files changed +18
-6
lines changed
main/java/org/springframework/boot/test/context
test/java/org/springframework/boot/test/rule Expand file tree Collapse file tree 2 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -154,14 +154,16 @@ public ContextLoader autoConfig(Class<?>... autoConfigurations) {
154
154
}
155
155
156
156
/**
157
- * Add the specified auto-configuration at the beginning so that it is
158
- * applied before any other existing auto-configurations, but after any
159
- * user configuration.
160
- * @param autoConfiguration the auto-configuration to add
157
+ * Add the specified auto-configurations at the beginning (in that order) so that it
158
+ * is applied before any other existing auto-configurations, but after any
159
+ * user configuration. If {@code A} and {@code B} are specified, {@code A} will
160
+ * be processed, then {@code B} and finally the rest of the existing
161
+ * auto-configuration.
162
+ * @param autoConfigurations the auto-configuration to add
161
163
* @return this instance
162
164
*/
163
- public ContextLoader autoConfigFirst (Class <?> autoConfiguration ) {
164
- this .autoConfigurations .addFirst ( autoConfiguration );
165
+ public ContextLoader autoConfigFirst (Class <?>... autoConfigurations ) {
166
+ this .autoConfigurations .addAll ( 0 , Arrays . asList ( autoConfigurations ) );
165
167
return this ;
166
168
}
167
169
Original file line number Diff line number Diff line change @@ -145,6 +145,16 @@ public void autoConfigureFirstIsAppliedProperly() {
145
145
assertThat (context .getBean ("a" )).isEqualTo ("a" ));
146
146
}
147
147
148
+ @ Test
149
+ public void autoConfigureFirstWithSeveralConfigsIsAppliedProperly () {
150
+ this .contextLoader .autoConfig (ConfigA .class , ConfigB .class )
151
+ .autoConfigFirst (AutoConfigA .class , AutoConfigB .class )
152
+ .load (context -> {
153
+ assertThat (context .getBean ("a" )).isEqualTo ("a" );
154
+ assertThat (context .getBean ("b" )).isEqualTo (1 );
155
+ });
156
+ }
157
+
148
158
@ Test
149
159
public void autoConfigurationIsAdditive () {
150
160
this .contextLoader .autoConfig (AutoConfigA .class )
You can’t perform that action at this time.
0 commit comments