Skip to content
This repository has been archived by the owner on Feb 23, 2023. It is now read-only.

TestExecutionListeners are not loaded in native image #1217

Closed
1 task done
sbrannen opened this issue Nov 5, 2021 · 0 comments
Closed
1 task done

TestExecutionListeners are not loaded in native image #1217

sbrannen opened this issue Nov 5, 2021 · 0 comments
Assignees
Labels
type: bug A general bug
Milestone

Comments

@sbrannen
Copy link
Contributor

sbrannen commented Nov 5, 2021

Overview

At some point during the migration to using Spring AOT for Spring TestContext Framework (TCF) support when executing tests within a native image, the TestExecutionListener implementations stopped being loaded.

Consequently, none of the native image tests for the sample applications actually loads an ApplicationContext. The reason is that a test ApplicationContext is only loaded if a registered TestExecutionListener invokes TestContext#getApplicationContext().

Analysis

TestExecutionListeners are configured via spring.factories and loaded reflectively.

The reason TestExecutionListener implementations are no longer loaded is that the DefaultFactoriesCodeContributor gets used for processing TestExecutionListener types in spring.factories, and that results in support being added to StaticSpringFactories for loading the TestExecutionListeners via SpringFactoriesLoader.loadFactories(). However, the TCF instead uses SpringFactoriesLoader.loadFactoryNames() and instantiates the TestExecutionListeners on its own via reflection.

Deliverables

  • Introduce a new FactoriesCodeContributor that handles TestExecutionListener implementations and generates the appropriate native image reflection configuration.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug A general bug
Development

No branches or pull requests

2 participants