Skip to content

WillKirkmanM/tester

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tester

A Universal Behavior Testing Tool for Any Executable Program, Featuring Deterministic Output Recording and Verification, CLI-Based Interaction, Structured .tester File Storage, and Fine-Grained Comparison of stdout, stderr, Exit Codes, and Runtime

Features

  • Universal: Works with any executable (Python scripts, compiled programs, shell commands, etc.)
  • Automatic Storage: Stores test expectations in .tester files alongside your code
  • Easy Verification: Compare current output against recorded expectations
  • Clean Management: Remove all test files with a single command
  • Detailed Output: Shows exactly what differs when tests fail

Installation

git clone https://github.com/WillKirkmanM/tester.git
cd tester
go build -o tester

Usage

Recording Test Output

Record the expected behavior of your program:

# Record Python script output
tester -record python script.py

# Record compiled program with arguments  
tester -record ./myprogram arg1 arg2

# Record any command
tester -record node app.js --port 3000

This creates a .{executable}.tester file containing the expected output, stderr, and exit code.

Verifying Against Recorded Output

Verify current behavior matches recorded expectations:

# Verify Python script
tester -verify python script.py

# Verify compiled program
tester -verify ./myprogram arg1 arg2

Cleaning Test Files

Remove all .tester files from current directory and subdirectories:

tester -clean

Examples

Example 1: Testing a Python Script

# Create a simple Python script
echo 'print("Hello, World!")' > hello.py

# Record expected output
tester -record python hello.py
# ✓ Recorded test output to .python.tester

# Verify it works
tester -verify python hello.py  
# ✅ Test PASSED - Output matches expected result

# Modify the script
echo 'print("Hello, Universe!")' > hello.py

# Verify again
tester -verify python hello.py
# ❌ Test FAILED - Output differs from expected
# 
# Expected:
# Hello, World!
# 
# Actual:  
# Hello, Universe!

Example 2: Testing a Go Program

# Build your Go program
go build -o calculator main.go

# Record behavior with different inputs
tester -record ./calculator add 5 3
tester -record ./calculator multiply 4 7

# Later, verify behavior hasn't changed
tester -verify ./calculator add 5 3
tester -verify ./calculator multiply 4 7

Example 3: Testing Error Conditions

# Record error output and exit codes
tester -record python nonexistent.py
# Records stderr and non-zero exit code

# Verify error handling still works
tester -verify python nonexistent.py

Test File Format

The .tester files are JSON formatted and contain:

{
  "result": {
    "stdout": "Hello, World!\n",
    "stderr": "",
    "exitCode": 0,
    "duration": "15.2ms"
  },
  "timestamp": "2025-05-31T10:30:00Z"
}

Use Cases

  • Language Testing: Verify compiler/interpreter behavior across versions
  • Regression Testing: Ensure program behavior doesn't change unexpectedly
  • CI/CD Integration: Automated behavior verification in pipelines
  • Documentation: Executable examples that stay up-to-date
  • Cross-Platform Testing: Verify consistent behavior across systems

Integration with CI/CD

# GitHub Actions example
- name: Verify Program Behavior
  run: |
    tester -verify python script.py
    tester -verify ./compiled-program

About

A Universal Behavior Testing Tool for Any Executable Program, Featuring Deterministic Output Recording and Verification, CLI-Based Interaction, Structured .tester File Storage, and Fine-Grained Comparison of stdout, stderr, Exit Codes, and Runtime

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors