TypedDevs / bashunit

A simple testing library for bash scripts. Test your bash scripts in the fastest and simplest way, discover the most modern bash testing library.
https://bashunit.typeddevs.com
MIT License
317 stars 27 forks source link

Remove exit code from test that fail #183

Open khru opened 11 months ago

khru commented 11 months ago

I've implemented an acceptance test over bashunit and my test failed because I needed it to know the exit code of the test and added to my output, even when this information was not relevant.

function test_bashunit_should_allow_test_drive_development() {
  local test_file=./tests/acceptance/fake_error_test.sh
  fixture=$(printf "Running ./tests/acceptance/fake_error_test.sh
\e[31m✗ Failed\e[0m: Error tdd with error code 127

\e[2mTests:     \e[0m \e[31m1 failed\e[0m, 1 total
\e[2mAssertions:\e[0m \e[31m0 failed\e[0m, 0 total")

  echo "
  #!/bin/bash
  function test_error_tdd() { assert_that_will_never_exist \"1\" \"1\" ; }" > $test_file

  set +e

  assertContains "$fixture" "$(./bashunit "$test_file")"
  assertGeneralError "$(./bashunit "$test_file")"

  rm $test_file
}

This line should

\e[31m✗ Failed\e[0m: Error tdd with error code 127

should be:

\e[31m✗ Failed\e[0m: Error tdd