Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions ci/scripts/run-openrewrite-spring-recipes-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
#
# Runs OpenRewrite Spring Recipes tests with the required Maven reactor options.
# Usage:
# ./ci/scripts/run-openrewrite-spring-recipes-test.sh
# ./ci/scripts/run-openrewrite-spring-recipes-test.sh org.springframework.sbm.OpenRewriteRecipeTest
set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)"

TEST_CLASS="${1:-org.springframework.sbm.OpenRewriteRecipeTest}"

cd "${REPO_ROOT}"
"${REPO_ROOT}/mvnw" \
-pl components/openrewrite-spring-recipes \
-am \
-Dtest="${TEST_CLASS}" \
-Dsurefire.failIfNoSpecifiedTests=false \
test
36 changes: 35 additions & 1 deletion docs/reference/testing.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,40 @@

Different classes exist to help writing tests for ``Recipe``s, ``Condition``s and ``Action``s.

=== Running OpenRewrite Spring Recipes Tests (English)

If you run tests in `components/openrewrite-spring-recipes` as a single module,
dependency resolution can fail because it depends on internal SNAPSHOT artifacts
(`sbm-core`, `sbm-support-boot`, `recipe-test-support`).
Also, when `-Dtest=...` is used, other reactor modules can fail with
"No tests matching pattern" unless configured explicitly.

Use the helper script below to run tests with the required options.

[source,bash]
.....
./ci/scripts/run-openrewrite-spring-recipes-test.sh
.....

To run a specific test class, pass the class name as an argument.

[source,bash]
.....
./ci/scripts/run-openrewrite-spring-recipes-test.sh org.springframework.sbm.OpenRewriteRecipeTest
.....

The script runs the following command:

[source,bash]
.....
./mvnw \
-pl components/openrewrite-spring-recipes \
-am \
-Dtest=org.springframework.sbm.OpenRewriteRecipeTest \
-Dsurefire.failIfNoSpecifiedTests=false \
test
.....

=== Windows & Linux

Linebreaks, encoding and path separator do (most probably will) differ depending on the OS the tests and the application
Expand Down Expand Up @@ -136,4 +170,4 @@ Changes will be reflected in the filesystem after this call.
<11> Start the docker image from the last step containing the migrated Spring application
<12> Create a RestTemplate
<13> Use the RestTemplate to retrive some data from the migrated Spring application running in Docker
<14> Verify the response
<14> Verify the response