This is an automated email from the ASF dual-hosted git repository. pottlinger pushed a commit to branch feature/RAT-442 in repository https://gitbox.apache.org/repos/asf/creadur-rat.git
commit 0bedba6d61bee86d7aa818e4725a8d1839bf8f73 Author: P. Ottlinger <[email protected]> AuthorDate: Sun Nov 9 00:23:30 2025 +0100 RAT-442: Improve debugging after migration to CLI 1.10.0 --- .../src/test/java/org/apache/rat/help/HelpTest.java | 4 ++-- .../test/java/org/apache/rat/testhelpers/TextUtils.java | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/apache-rat-core/src/test/java/org/apache/rat/help/HelpTest.java b/apache-rat-core/src/test/java/org/apache/rat/help/HelpTest.java index e3e99476..a844d7b0 100644 --- a/apache-rat-core/src/test/java/org/apache/rat/help/HelpTest.java +++ b/apache-rat-core/src/test/java/org/apache/rat/help/HelpTest.java @@ -42,10 +42,10 @@ public class HelpTest { for (Option option : opts.getOptions()) { if (option.getOpt() != null) { - TextUtils.assertContains("-" + option.getOpt() + (option.getLongOpt() == null ? " " : ","), result); + TextUtils.assertContains(option, "-" + option.getOpt() + (option.getLongOpt() == null ? " " : ","), result); } if (option.getLongOpt() != null) { - TextUtils.assertContains("--" + option.getLongOpt() + " ", result); + TextUtils.assertContains(option, "--" + option.getLongOpt() + " ", result); } } diff --git a/apache-rat-core/src/test/java/org/apache/rat/testhelpers/TextUtils.java b/apache-rat-core/src/test/java/org/apache/rat/testhelpers/TextUtils.java index e90a30b9..68e31a5f 100644 --- a/apache-rat-core/src/test/java/org/apache/rat/testhelpers/TextUtils.java +++ b/apache-rat-core/src/test/java/org/apache/rat/testhelpers/TextUtils.java @@ -26,6 +26,8 @@ import java.io.IOException; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.util.regex.Pattern; + +import org.apache.commons.cli.Option; import org.apache.commons.io.IOUtils; /** @@ -78,6 +80,18 @@ public class TextUtils { .isTrue(); } + /** + * Asserts that a string is contained within another string and allows to print the related option. + * @param option The current option to search in via parameter find. + * @param find The string to find. + * @param target The string to search. + */ + public static void assertContains(final Option option, final String find, final String target) { + assertThat(target.contains(find)).as(() -> + format("Target option '%s' is not properly found in the text: %s%n%s", option, find, target)) + .isTrue(); + } + /** * Asserts that a string is contained exactly a specified number of times within another string. * @param times The number of times to find the string in the target.
