From e2b75574203eeb194efe9bc66e168255b03f2ac8 Mon Sep 17 00:00:00 2001 From: Jimisola Laursen Date: Tue, 3 Mar 2026 21:08:41 +0100 Subject: [PATCH] test(fixtures): add test project with SVCs, tests, and reqstool status validation --- tests/fixtures/test_project/README.md | 63 ++++++++++++++++ .../docs/reqstool/requirements.yml | 15 ++++ .../reqstool/software_verification_cases.yml | 8 ++ tests/fixtures/test_project/pom.xml | 73 +++++++++++++++++++ .../io/github/reqstool/example/Hello.java | 11 +++ .../io/github/reqstool/example/HelloTest.java | 16 ++++ 6 files changed, 186 insertions(+) create mode 100644 tests/fixtures/test_project/README.md create mode 100644 tests/fixtures/test_project/docs/reqstool/requirements.yml create mode 100644 tests/fixtures/test_project/docs/reqstool/software_verification_cases.yml create mode 100644 tests/fixtures/test_project/pom.xml create mode 100644 tests/fixtures/test_project/src/main/java/io/github/reqstool/example/Hello.java create mode 100644 tests/fixtures/test_project/src/test/java/io/github/reqstool/example/HelloTest.java diff --git a/tests/fixtures/test_project/README.md b/tests/fixtures/test_project/README.md new file mode 100644 index 0000000..71686e4 --- /dev/null +++ b/tests/fixtures/test_project/README.md @@ -0,0 +1,63 @@ +# mypackage + +Minimal test project for manual validation of `reqstool-java-maven-plugin`. + +## Prerequisites + +- Java 21+ +- Maven 3.9+ +- `reqstool` CLI: `pip install reqstool` + +## Validation + +Run all commands from `tests/fixtures/test_project/`. + +### 1 — Build + +```bash +mvn verify +``` + +This compiles (triggering the APT annotation processor), runs tests, and assembles the reqstool zip. + +Expected output (key lines): +``` +[INFO] Processing annotations: [io.github.reqstool.annotations.Requirements] +[INFO] Writing Requirements Annotations data to: target/generated-sources/annotations/resources/annotations.yml + +[INFO] Processing annotations: [io.github.reqstool.annotations.SVCs] +[INFO] Writing Requirements Annotations data to: target/generated-test-sources/test-annotations/resources/annotations.yml + +[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 + +[INFO] Assembling zip file: target/reqstool/mypackage-0.1.0-reqstool.zip +[INFO] BUILD SUCCESS +``` + +### 2 — Check artefacts + +```bash +# zip must exist +ls target/reqstool/mypackage-0.1.0-reqstool.zip + +# zip must contain all reqstool files + test results +unzip -l target/reqstool/mypackage-0.1.0-reqstool.zip +``` + +Expected entries in the zip: +- `mypackage-0.1.0-reqstool/requirements.yml` +- `mypackage-0.1.0-reqstool/software_verification_cases.yml` +- `mypackage-0.1.0-reqstool/annotations.yml` +- `mypackage-0.1.0-reqstool/test_results/TEST-io.github.reqstool.example.HelloTest.xml` +- `mypackage-0.1.0-reqstool/reqstool_config.yml` + +### 3 — Run reqstool status + +The zip is self-contained (test results included), so just extract and run: + +```bash +unzip -o target/reqstool/mypackage-0.1.0-reqstool.zip -d /tmp/mypackage-reqstool +reqstool status local -p /tmp/mypackage-reqstool/mypackage-0.1.0-reqstool +``` + +Expected: all green — `REQ_001` implemented, `T1 P1`, no missing tests or SVCs. diff --git a/tests/fixtures/test_project/docs/reqstool/requirements.yml b/tests/fixtures/test_project/docs/reqstool/requirements.yml new file mode 100644 index 0000000..5369e83 --- /dev/null +++ b/tests/fixtures/test_project/docs/reqstool/requirements.yml @@ -0,0 +1,15 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/reqstool/reqstool-client/main/src/reqstool/resources/schemas/v1/requirements.schema.json + +metadata: + urn: mypackage + variant: microservice + title: Mypackage Requirements + url: https://github.com/reqstool/reqstool-java-maven-plugin + +requirements: + - id: REQ_001 + title: Hello function + significance: shall + description: The hello method shall return "hello". + categories: ["functional-suitability"] + revision: "0.1.0" diff --git a/tests/fixtures/test_project/docs/reqstool/software_verification_cases.yml b/tests/fixtures/test_project/docs/reqstool/software_verification_cases.yml new file mode 100644 index 0000000..c2da77f --- /dev/null +++ b/tests/fixtures/test_project/docs/reqstool/software_verification_cases.yml @@ -0,0 +1,8 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/reqstool/reqstool-client/main/src/reqstool/resources/schemas/v1/software_verification_cases.schema.json + +cases: + - id: SVC_001 + requirement_ids: ["REQ_001"] + title: "Hello method returns hello" + verification: automated-test + revision: "0.1.0" diff --git a/tests/fixtures/test_project/pom.xml b/tests/fixtures/test_project/pom.xml new file mode 100644 index 0000000..d65a8b5 --- /dev/null +++ b/tests/fixtures/test_project/pom.xml @@ -0,0 +1,73 @@ + + + 4.0.0 + io.github.reqstool.example + mypackage + 0.1.0 + mypackage + Minimal test project for reqstool-java-maven-plugin + + + 21 + 21 + 21 + true + + + + + io.github.reqstool + reqstool-java-annotations + 1.0.0 + + + org.junit.jupiter + junit-jupiter-api + 6.0.3 + test + + + + + + + maven-compiler-plugin + 3.15.0 + + + + io.github.reqstool + reqstool-java-annotations + 1.0.0 + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.5.5 + + + io.github.reqstool + reqstool-maven-plugin + 1.0.4 + + + + assemble-and-attach-zip-artifact + + + + + ${project.basedir}/docs/reqstool + + target/surefire-reports/*.xml + + + + + + diff --git a/tests/fixtures/test_project/src/main/java/io/github/reqstool/example/Hello.java b/tests/fixtures/test_project/src/main/java/io/github/reqstool/example/Hello.java new file mode 100644 index 0000000..c22a0c9 --- /dev/null +++ b/tests/fixtures/test_project/src/main/java/io/github/reqstool/example/Hello.java @@ -0,0 +1,11 @@ +package io.github.reqstool.example; + +import io.github.reqstool.annotations.Requirements; + +public class Hello { + + @Requirements("REQ_001") + public String hello() { + return "hello"; + } +} diff --git a/tests/fixtures/test_project/src/test/java/io/github/reqstool/example/HelloTest.java b/tests/fixtures/test_project/src/test/java/io/github/reqstool/example/HelloTest.java new file mode 100644 index 0000000..2bb7fcc --- /dev/null +++ b/tests/fixtures/test_project/src/test/java/io/github/reqstool/example/HelloTest.java @@ -0,0 +1,16 @@ +package io.github.reqstool.example; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; + +import io.github.reqstool.annotations.SVCs; + +class HelloTest { + + @Test + @SVCs("SVC_001") + void testHello() { + assertEquals("hello", new Hello().hello()); + } +}