Skip to content

A console command for regression testing console commands. Written in Python.

Notifications You must be signed in to change notification settings

Jefficus/backcheck

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

Backcheck is a simple regression testing tool for command line scripts and apps. It's designed for use with VERY simple programs that have no interactive behavior and dump all of its output to STDOUT. I use it to make sure that new changes to a tool don't break previously working features.

It works on a simple principle: when a command works correctly for a particular combination of arguments, take a snapshot of the command invokation and its output and store those in a vault. At any time in the future, all snapshots in the vault can be retested to be sure they still produce the correct output.

Usage

backcheck [options]  
backcheck -h | --help  
backcheck -v | --verbose  
backcheck -V | --version  

Options

-c DIR       # Confirm all recorded snapshots are still correct  
-l DIR       # List all snapshotted command lines  
-r CMDSTR    # Record snapshot of CMDSTR into the vault  
-f           # Force -r to overwrite the existing snapshot of CMDSTR  
-t CMDSTR    # Verify snapshot of given CMDSTR, if one exists  
-v           # Display verbose output  
-V           # Display version information  

Example Usage

There are three basic operations:

 Record a new command snapshot with:  
		backcheck -r "mycommand arg1 arg2..."

 Confirm correct behavior of a specific command with:  
	  backcheck -t "mycommand arg1 arg2..."

 Confirm correct behavior of all snapshots with:  
	  backcheck -c VAULTDIR

The Vault

By default, the vault directory is stored in ./test-mycommand, and that vault is created automatically if it does not already exist.

Snapshot files in the vault are named with an MD5 hash of the command line being recorded, and the contents of the file are as follows:

 Line 1: the command line that generated the output

 Line 2+: the generated output

Verification

Whether invoked individually or for all snapshots, verification is performed by running the command line again, capturing its output, and comparing to the snapshot content. If they are identical, the test passes. If they differ in any way, the command fails.

Any data files required for testing can be stored in the vault directory and will be ignored by the -c command so long as the filename begins with 'data'. Files that include non-hexadecimal characters will also be ignored, although they will be listed as unknown files in the -l listing.

State Management

Bear in mind that the intention is to be VERY simple. In my world, that means each test is completely independant. If you need setup and teardown capabilities, you probably want a more full-featured regression testing tool.

Created 2018 by Jefferson Smith
Check out my tools, videos, and novels at http://creativityhacker.ca

About

A console command for regression testing console commands. Written in Python.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages