Skip to content

Latest commit

 

History

13 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Testable Contract Graph. Simple What and How To.

This tool provides a structured way to define requirements, understand their dependencies, and verify that each requirement is truly satisfied.

The workflow is intentionally simple and iterative: Start with the goal → work backward to understand dependencies → define verifications → ( ... verify → close dependency → ...)
Inspired by a linear "IN ORDER TO, AS A, I NEED A" sequence, but composed as a hierarchy in order to avoid atomic dependencies.

Step #1: Start with the goal:

Add root task to the contractsGraph/moon.yml

isDocPrinted:
    command: "bash ./isDocPrinted.sh"
stateDiagram-v2
    isDocPrinted
Loading

Step #2: Work backwards to define dependencies:

Add dependency task

isPrinterOn:
    command: "bash ./isPrinterOn.sh"
    deps: 
        - "isDocPrinted"
stateDiagram-v2
    isDocPrinted --> isPrinterOn: require
Loading

Step #3. Add verification script #1 (manual, isDocPrinted.sh):

#!/bin/bash

set -e

echo ""
echo " file: isDocPrinted.sh"
echo " description: Verifying if the document is ready."
echo ""
echo " Please perform the following in another terminal:"
echo " 1. Go to the desk and ask for the paper."
echo ""
echo "Send OK if login succeeded, press ENTER if login failed."
read VALUE

if [ -n "$VALUE" ]; then
    echo "✅ [tty] verification passed: Doc is received"
    exit 0
else
    echo "❌ [tty] verification failed: Something gone wrong"
    exit 1
fi

Step #4. Add verification script #2 (auto, isPrinterOn.sh):

#!/bin/bash

set -e

echo ""
echo " file: isPrinterOn.sh"
echo " description: Verifying if printer is ready."
echo ""

VALUE="$(curl -s -o /dev/null -w '%{http_code}' http://printer:8080)"

if [ "$VALUE" = "200" ]; then
    echo "✅ [tty] verification passed: Printer is ready"
    exit 0
else
    echo "❌ [tty] verification failed: Printer is offline"
    exit 1
fi

Step #5: Run root task verification

moon run contractsGraph:isDocPrinted

Step #6: Export tasks graph

moon task-graph --json > ./test/moonGraphTestData.json

Step #7: Get the initial state

moon2merm --moonGraph ./test/moonGraphTestData.json --runReport ./.moon/cache/runReport.json --outdir ./test

stateDiagram-v2

🔵isDocPrinted --> 🔵isPrinterOn : 🔵require
🔵isPrinterOn --> 🟢void : 🟢require

Loading

Step #8: Do the task

  • Turn on the printer

Step #9: Verify

stateDiagram-v2

🔵isDocPrinted --> 🟢isPrinterOn : 🟢require
🟢isPrinterOn --> 🟢void : 🟢require

Loading

Step #10 (8): Do the task

  • Print the doc

Step #11 (9): Verify

stateDiagram-v2

🟢isDocPrinted --> 🟢isPrinterOn : 🟢require
🟢isPrinterOn --> 🟢void : 🟢require

Loading

About

Сan requirements be aligned and verified within the complex hierarchy?

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages