Getting Started with Bash Testing with Bats

This page summarizes the projects mentioned and recommended in the original post on dev.to

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • getting-started-with-bash-testing

    Example Bash Project to get started with testing with Bats.

  • If you have questions or suggestions feel free to open a Discussion on the GitHub repository or contact me via Twitter or email.

  • git-auto-commit-action

    Automatically commit and push changed files back to GitHub with this GitHub Action for the 80% use case.

  • Note: I'm by no means an expert when it comes to writing tests in Bash. All my knowledge comes from maintaining a GitHub Action called git-auto-commit. While I've developed the tests for git-auto-commit, I wished there was a resource which would guide me through all the steps necessary to add a test suite to my bash scripts. That's why this guide exists.

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • bats-core

    Bash Automated Testing System

  • In this guide I would like to give you an introduction on how you can start writing tests for your Bash scripts by using Bats.

  • bash_shell_mock

    Discontinued A shell script mocking utility/framework for the BASH shell

  • I won't add mocking capabilities to our example project here, but I would like to give a short overview on how you can add Mocking to your Bats tests. For my git-auto-commit project I've used Shellmock for a period of time, to mock all calls to git. (In hindsight, that was a mistake. Full story can be read here).

  • bats-assert

    Common assertions for Bats

  • For example for me assert_line 'usage: foo ' is much easier to read and understand than ["${lines[0]}" = "usage: foo " ]. (Head over to the bats-assert repository to learn more about the available assertions).

  • bats-support

    Supporting library for Bats test helpers

  • bats-assert and bats-support are two libraries which will make writing Bash tests much more intuitive.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts