You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|This can either be one of the predefined values `uncommitted-changes`, `reference-commit`, `default` or the fully-qualified class name of a `FileModificationDetector` that will be used to inspect which files of the projects have been changed.
77
+
As the name suggests, `uncommitted-changes` will only consider changed files not already committed.
78
+
`reference-commit` will consider all files changed since a given Git commit provided via `spring.modulith.test.reference-commit`, particularly useful CI environments in which that property could point to the commit hash of the last successful build.
79
+
`default` detects all uncomitted changes and ones that have not been pushed to the current branch's tracking branch which is primarily useful for local development.
80
+
81
+
|`spring.modulith.test.reference-commit`
82
+
|none
83
+
|The commit hash of to which to calculate the set of changed files.
84
+
Usually propagated in CI environments to consider all changes since the last successful build.
// scenario will be pre-customized with logic defined in MyCustomizer
366
-
}
364
+
@Test
365
+
fun myTestCase(scenario: Scenario) {
366
+
// scenario will be pre-customized with logic defined in MyCustomizer
367
+
}
367
368
368
-
class MyCustomizer : ScenarioCustomizer {
369
+
class MyCustomizer : ScenarioCustomizer {
369
370
370
-
override fun getDefaultCustomizer(method: Method, context: ApplicationContext): UnaryOperator<ConditionFactory> {
371
-
return UnaryOperator { conditionFactory -> … }
372
-
}
373
-
}
371
+
override fun getDefaultCustomizer(method: Method, context: ApplicationContext): UnaryOperator<ConditionFactory> {
372
+
return UnaryOperator { conditionFactory -> … }
373
+
}
374
+
}
374
375
}
375
376
----
376
377
======
378
+
379
+
[[change-aware-test-execution]]
380
+
== Change-Aware Test Execution
381
+
382
+
As of version 1.3, Spring Modulith ships with a JUnit Jupiter extension that will optimize the execution of tests, so that tests not affected by changes to the project will be skipped.
383
+
To enable that optimization, declare the `spring-modulith-junit` artifact as a dependency in test scope:
384
+
385
+
[source, xml]
386
+
----
387
+
<dependency>
388
+
<groupId>org.springframework.modulith</groupId>
389
+
<artifactId>spring-modulith-junit</artifactId>
390
+
<scope>test</scope>
391
+
</dependency>
392
+
----
393
+
394
+
Tests will be selected for execution if they reside in either a root module, a module that has seen a change or one that transitively depends on one that has seen a change.
395
+
The optimization will back off optimizing the execution under the following circumstances:
396
+
397
+
* The test execution originates from an IDE as we assume the execution is triggered explicitly.
398
+
* The set of changes contains a change to a resource related to a build system (`pom.xml`, `build.gradle`, `gradle.properties`).
399
+
* The set of changes contains a change to any classpath resource.
400
+
* The project does not contain a change at all (typical in a CI build).
401
+
402
+
To optimize the execution in a CI environment, you need to populate the xref:appendix.adoc#configuration-properties[`spring.modulith.test.reference-commit` property] pointing to the commit of the last successful build and make sure that the build checks out all commits up to the reference one.
403
+
The algorithm detecting changes to application modules will then consider all files changed in that delta.
404
+
To override the project modification detection, declare an implementation of `FileModificationDetector` via the xref:appendix.adoc#configuration-properties[`spring.modulith.test.file-modification-detector` property].
0 commit comments