# Testing Your Scripts

## Static Code Analysis

The bash scripts generated by bashly are
[shellcheck](https://github.com/koalaman/shellcheck#readme) compliant, and
[shfmt](https://github.com/mvdan/sh) 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
```

## Testing Frameworks

When your scripts grow more elaborate, you can test them with any Bash testing
framework you prefer.

One advantage of Bashly projects is that user-developed logic usually lives in
separate files under `src`. This makes it easier to test only the unit under
test by sourcing the relevant file directly, instead of invoking the entire
generated script for every test.

This approach works well for unit tests around helper functions, command logic,
and edge cases, while higher-level integration tests can still exercise the
generated CLI as an end user would.
