# Testing Your Scripts

# Static Code Analysis

The bash scripts generated by bashly are shellcheck compliant, and shfmt compliant.

This means that you can use these tools to ensure that any custom code you use in your script, is also valid.

Note that when testing with shfmt, you should specify an indentation of 2 spaces, and case indentation rules:

$ shfmt --diff --case-indent --indent 2 yourscript

# Approval Testing

In cases where your scripts are more elaborate, or when you wish to ensure your scripts behave as expected, you can use any bash testing framework to test your scripts.

One such lightweight framework, is Approvals.bash, which lets you test any command in your script, and prompting you for interactive approval of its output. Whenever the output changes, you will be prompted again to approve it.

A sample test script looks like this:

#!/usr/bin/env bash
source approvals.bash

approve "your-cli --help"
approve "your-cli command --arg"
# ... more tests