Skip to content

Commit

Permalink
Migrate "Failing" test cases to regular tests
Browse files Browse the repository at this point in the history
This commit replaces the use of EngineTestKit to test scenarios where
bean override could not process the test class. There is no need to
run an actual test for this as:

1. Regular integration tests are already validating that adding the
annotation triggers the processing as part of executing the test.
2. The entry point is a ContextCustomizer that can easily be invoked
in a regular test.

As part of harmonizing this, AbstractTestBeanIntegrationTestCase can
be nested, and BeanOverrideTestSuite serve no purpose. The tests can
be executed in an IDE without any special setup.
  • Loading branch information
snicoll committed Jun 12, 2024
1 parent 1318f65 commit 3f2d9c3
Show file tree
Hide file tree
Showing 18 changed files with 433 additions and 896 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@

import java.util.Collections;

import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.lang.Nullable;
import org.springframework.test.context.ContextCustomizer;
import org.springframework.test.context.MergedContextConfiguration;

import static org.mockito.Mockito.mock;

/**
* Test utilities for {@link BeanOverrideContextCustomizer} that are public so
Expand All @@ -44,4 +48,17 @@ public static ContextCustomizer createContextCustomizer(Class<?> testClass) {
return factory.createContextCustomizer(testClass, Collections.emptyList());
}

/**
* Configure the given {@linkplain ConfigurableApplicationContext application
* context} for the given {@code testClass}.
* @param testClass the test to process
* @param context the context to configure
*/
public static void configureApplicationContext(Class<?> testClass, ConfigurableApplicationContext context) {
ContextCustomizer contextCustomizer = createContextCustomizer(testClass);
if (contextCustomizer != null) {
contextCustomizer.customizeContext(context, mock(MergedContextConfiguration.class));
}
}

}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 3f2d9c3

Please sign in to comment.