diff --git a/.github/workflows/commit.yml b/.github/workflows/commit.yml index 82cca33..c2b69a9 100644 --- a/.github/workflows/commit.yml +++ b/.github/workflows/commit.yml @@ -21,9 +21,6 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Validate Gradle wrapper - uses: gradle/wrapper-validation-action@v3 - - name: Set up JDK 25 uses: actions/setup-java@v4 with: diff --git a/hello-xtc/build.gradle.kts b/hello-xtc/build.gradle.kts index 9fc1534..abe9ac3 100644 --- a/hello-xtc/build.gradle.kts +++ b/hello-xtc/build.gradle.kts @@ -27,6 +27,15 @@ xtcRun { } } +// Note: The xtcTest task auto-discovers test modules from src/test/x. +// No explicit module configuration is needed - just place test modules in +// the test source set and they will be run as part of the build lifecycle. +// You can optionally configure test behavior here: +// xtcTest { +// failOnTestFailure = true // default +// // includes/excludes can be used to filter test modules +// } + // Print version information val printVersionInfo by tasks.registering { val xtcVersionTask = tasks.named("xtcVersion") diff --git a/hello-xtc/src/main/x/HelloWorld.x b/hello-xtc/src/main/x/HelloWorld.x index ead2daf..90a144f 100644 --- a/hello-xtc/src/main/x/HelloWorld.x +++ b/hello-xtc/src/main/x/HelloWorld.x @@ -1,7 +1,19 @@ module HelloWorld { + /** + * Format a greeting from the provided parts. + * + * @param prefix the greeting prefix (e.g., "Hello ") + * @param middle the middle part (e.g., "there, ") + * @param name the name to greet (e.g., "World") + * + * @return the formatted greeting string with an exclamation mark + */ + static String formatGreeting(String prefix, String middle, String name) { + return $"{prefix}{middle}{name}!"; + } + void run(String[] args = []) { @Inject Console console; - //assert:debug; - console.print($"{args[0]}{args[1]}{args[2]}!"); + console.print(formatGreeting(args[0], args[1], args[2])); } } diff --git a/hello-xtc/src/test/x/HelloWorldTest.x b/hello-xtc/src/test/x/HelloWorldTest.x new file mode 100644 index 0000000..74cc295 --- /dev/null +++ b/hello-xtc/src/test/x/HelloWorldTest.x @@ -0,0 +1,44 @@ +/** + * Unit tests for the HelloWorld module's greeting functionality. + * + * This test module demonstrates how to write xunit tests that are run + * as part of the Gradle build lifecycle via the `testXtc` task. + */ +module HelloWorldTest { + package greeting import HelloWorld; + + /** + * Tests for the formatGreeting() function. + */ + class GreeterTest { + @Test + void shouldFormatBasicGreeting() { + String result = greeting.formatGreeting("Hello ", "there, ", "World"); + assert result == "Hello there, World!"; + } + + @Test + void shouldFormatGreetingWithCustomName() { + String result = greeting.formatGreeting("Hello ", "there, ", "Marcus"); + assert result == "Hello there, Marcus!"; + } + + @Test + void shouldFormatGreetingWithEmptyParts() { + String result = greeting.formatGreeting("", "", "Test"); + assert result == "Test!"; + } + + @Test + void shouldFormatGreetingWithDifferentPrefix() { + String result = greeting.formatGreeting("Hi ", "dear ", "Friend"); + assert result == "Hi dear Friend!"; + } + + @Test + void shouldAlwaysAppendExclamationMark() { + String result = greeting.formatGreeting("A", "B", "C"); + assert result.endsWith("!"); + } + } +}