Skip to content
Merged
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
65 changes: 65 additions & 0 deletions tests/fixtures/test_project/README.md
Original file line number Diff line number Diff line change
@@ -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.
44 changes: 44 additions & 0 deletions tests/fixtures/test_project/build.gradle
Original file line number Diff line number Diff line change
@@ -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')
}
15 changes: 15 additions & 0 deletions tests/fixtures/test_project/docs/reqstool/requirements.yml
Original file line number Diff line number Diff line change
@@ -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"
Original file line number Diff line number Diff line change
@@ -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"
1 change: 1 addition & 0 deletions tests/fixtures/test_project/settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rootProject.name = 'mypackage'
Original file line number Diff line number Diff line change
@@ -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";
}
}
Original file line number Diff line number Diff line change
@@ -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());
}
}
Loading