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

TestExecutionListeners are not loaded in native image #1217

Closed

Description

@sbrannen

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.

Activity

  1. self-assigned this
    on Nov 5, 2021
  2. added this to the 0.11.0-RC1 milestone on Nov 5, 2021
  3. added a commit that references this issue on Feb 17, 2024
    4498c7c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

type: bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions