Skip to content

Conversation

@ValentinBossi
Copy link
Contributor

@ValentinBossi ValentinBossi commented Nov 29, 2025

resolves #1438


if (!changes.hasClassChanges()) {
return enabled("No source file changes detected.");
var environment = new StandardEnvironment();
Copy link
Contributor Author

@ValentinBossi ValentinBossi Nov 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it make sense to adjust ConditionContext so that here is no need to create StandardEnvironment?
or in another way so that also StateStore can profit from a simplification (there is also an instantiation of StandardEnvironment)?

also a test is missing. im not sure how you prefer to structure the test setup, particularly regarding setting the value in application.yml to skip all tests when no class changes are detected.

Copy link
Member

@odrotbohm odrotbohm Nov 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use StateStore.getChanges() to look up the new property and massage its presence into a Change.NONE_AND_PROCEED or Change.NONE_AND_SKIP constant. We need the StandardEnvironment processing there anyway to read other properties from Boot standard locations.

I've just pushed a change to main to slightly refactor the code a bit so that the creation of a Changes instance now depends solely on an Environment. I've added a unit test for the existing property lookup in ChangesFactoryUnitTests. You should be able to add tests there more easily.

var environment = new StandardEnvironment();
ConfigDataEnvironmentPostProcessor.applyTo(environment);

return "execute-none".equals(environment.getProperty("spring.modulith.test.on-no-changes"))
Copy link
Contributor Author

@ValentinBossi ValentinBossi Nov 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a switch expression could be used here. ("execute-none", "execute-all")
but i would actually prefer a boolean but a renaming of "spring.modulith.test.on-no-changes" would then make sense like "spring.modulith.test.skip-all-on-no-class-changes"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's stick with an enum here, please. True/false hardly make any sense without context, especially when handed as parameters into methods. The enum can be a nested type of Changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enum sounds great. i just dont know if i understand it correctly.
i pushed an attempt.

…nfiguration on-no-changes=execute-none is set
@ValentinBossi
Copy link
Contributor Author

in Changes boolean contains(Class<?> type) is unused


if (!changes.hasClassChanges()) {
return enabled("No source file changes detected.");
var environment = new StandardEnvironment();
Copy link
Member

@odrotbohm odrotbohm Nov 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use StateStore.getChanges() to look up the new property and massage its presence into a Change.NONE_AND_PROCEED or Change.NONE_AND_SKIP constant. We need the StandardEnvironment processing there anyway to read other properties from Boot standard locations.

I've just pushed a change to main to slightly refactor the code a bit so that the creation of a Changes instance now depends solely on an Environment. I've added a unit test for the existing property lookup in ChangesFactoryUnitTests. You should be able to add tests there more easily.

var environment = new StandardEnvironment();
ConfigDataEnvironmentPostProcessor.applyTo(environment);

return "execute-none".equals(environment.getProperty("spring.modulith.test.on-no-changes"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's stick with an enum here, please. True/false hardly make any sense without context, especially when handed as parameters into methods. The enum can be a nested type of Changes.

},
{
"name": "spring.modulith.test.on-no-changes",
"type": "java.lang.String",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can express an enum here directly. I just don't know how from the top of my head. I solely used hints in the other cases, as with those, we both support well-known values and custom strings.

Copy link
Contributor Author

@ValentinBossi ValentinBossi Nov 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

neither do i. i did searching in spring boot repo an example but after some time i gave up.
i pushed a new version.

@odrotbohm
Copy link
Member

Thank you very much. I'll take it from here.

odrotbohm pushed a commit that referenced this pull request Dec 1, 2025
odrotbohm added a commit that referenced this pull request Dec 1, 2025
Original pull request: GH-1484.
@odrotbohm
Copy link
Member

That's polished and merged. Thanks!

@odrotbohm odrotbohm closed this Dec 1, 2025
odrotbohm pushed a commit that referenced this pull request Dec 1, 2025
odrotbohm added a commit that referenced this pull request Dec 1, 2025
Original pull request: GH-1484.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow skipping all tests if no changes are detected

2 participants