Unit Tests

For nice and tested code

Made by the fine team at TypedDevs, BashUnit is a great piece of software, with intuitive assertions and clean test reports.

To write BashUnit tests in Sh:erpa, place them in the tests directory, then run sh t from the root directory of your project.

First Example of a test file

As a first example of what it can look like, here is an excerpt of one of the tests, checking if the import function defined in .sherpa/basecamp.sh can indeed source a remote .sh file.

# /.sherpa/tests/basecamp_test.sh

. ~/.sherpa/basecamp.sh

function test_import_url_function() {

  # Test
  import -u "https://codeberg.org/AndiKod/testo/raw/branch/master/greet.sh"
  # Assert
  assert_same "$(hey)" "Hello!"

}

We'll have more examples or even a quick "CheatSheet" with the availbale assertions, but you can anyway learn about them on the official docs.