diff --git a/tests/fixtures/test_project/README.md b/tests/fixtures/test_project/README.md new file mode 100644 index 0000000..fe82975 --- /dev/null +++ b/tests/fixtures/test_project/README.md @@ -0,0 +1,65 @@ +# mypackage + +Minimal test project for manual validation of `reqstool-java-gradle-plugin`. + +## Prerequisites + +- Java 21+ +- Gradle 8+ (or use the repo's `gradlew` wrapper if available) +- `reqstool` CLI: `pip install reqstool` + +## Validation + +Run all commands from `tests/fixtures/test_project/`. + +### 1 — Build + +```bash +gradle build +``` + +This runs compilation (triggering the APT annotation processor), tests, and +`assembleRequirements` in one step. + +Expected output: +``` +> Task :compileJava +Note: Processing annotations: [io.github.reqstool.annotations.Requirements] +Note: Writing Requirements Annotations data to: build/.../annotations.yml + +> Task :compileTestJava +Note: Processing annotations: [io.github.reqstool.annotations.SVCs] +Note: Writing Requirements Annotations data to: build/.../annotations.yml + +> Task :test +> Task :assembleRequirements +BUILD SUCCESSFUL +``` + +### 2 — Check artefacts + +```bash +# zip must exist +ls build/reqstool/mypackage-0.1.0-reqstool.zip + +# zip must contain all reqstool files + test results +unzip -l build/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 build/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/build.gradle b/tests/fixtures/test_project/build.gradle new file mode 100644 index 0000000..c56e99b --- /dev/null +++ b/tests/fixtures/test_project/build.gradle @@ -0,0 +1,44 @@ +plugins { + id 'java' + id 'io.github.reqstool.gradle-plugin' version '0.1.0' +} + +group = 'io.github.reqstool.example' +version = '0.1.0' + +java { + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 +} + +repositories { + mavenCentral() +} + +dependencies { + implementation 'io.github.reqstool:reqstool-java-annotations:1.0.0' + annotationProcessor 'io.github.reqstool:reqstool-java-annotations:1.0.0' + + testImplementation platform('org.junit:junit-bom:6.0.3') + testImplementation 'org.junit.jupiter:junit-jupiter-api' + testAnnotationProcessor 'io.github.reqstool:reqstool-java-annotations:1.0.0' + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' +} + +test { + useJUnitPlatform() +} + +requirementsTool { + datasetPath = file('docs/reqstool') + testResults = ['build/test-results/**/*.xml'] +} + +tasks.named('build') { + finalizedBy tasks.named('assembleRequirements') +} + +tasks.named('assembleRequirements') { + dependsOn tasks.named('test') +} 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..d543b61 --- /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-gradle-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/settings.gradle b/tests/fixtures/test_project/settings.gradle new file mode 100644 index 0000000..93c2cdf --- /dev/null +++ b/tests/fixtures/test_project/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'mypackage' 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()); + } +}