Skip to content

Support text blocks for inlined properties in @TestPropertySource #31053

@sbrannen

Description

@sbrannen

Multiple inlined properties can currently only be supplied as an array of strings:

@TestPropertySource(properties = {
    "key1 = value1",
    "key2 = value2"
})

It would be nice to be able to use a single text block (or multiple text blocks):

@TestPropertySource(properties = """
    key1 = value1
    key2 = value2
    """
)

However, TestPropertySourceUtils.convertInlinedPropertiesToMap(String...) currently throws an exception if a single String contains more than one key-value pair.

That check made sense when we expected users to supply one key-value pair per string in an array, but that restriction no longer makes sense when text blocks are taken into consideration.

We should therefore remove that restriction and allow users to supply inlined properties as a text block.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions