Skip to content

@Value injection for test method parameters inconsistent with other places #1234

@sdedic

Description

@sdedic

Expected Behavior

I expected that @Value("${propertyName}") will evaluate to the property's value, similar to places where e.g. configuration property is injected into production class' field or consructor parameter.

@Value should behave the same way for test method parameters, regular bean constructor/executable method parameters and bean fields.

Actual Behaviour

For test method parameter, @Value("propertyname") works, however @Value("${propertyName"}) first interpolates the property then attempts to find a property matching the interpolated result - which fails.
Similar for @Value("#{expression"}) that evaluates the xpression first, then attempts to locate property whose name matches the expression's result.

Steps To Reproduce

  1. Clone https://github.com/sdedic/micronaut-dbbugs2/tree/value_annotation_inconsistent, value_annotation_inconsistent branch
  2. Run PropertyExampleTest

Environment Information

  • Ubuntu Linux 22.04
  • JDK 21

Example Application

https://github.com/sdedic/micronaut-dbbugs2/tree/value_annotation_inconsistent

Version

4.7.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions