sstephenson / bats

Bash Automated Testing System
MIT License
7.12k stars 519 forks source link

Show Why Tests Have Failed #271

Open JimLynchCodes opened 4 years ago

JimLynchCodes commented 4 years ago

Hi!

Here's a simple example of my code:

#!/usr/bin/env bash

echo "Hello, Worldy!"

and then the bats test:

#!/usr/bin/env bash

# local version: 1.1.0.0

@test "Say Hi!" {
  run bash hello_world.sh

  [[ $status -eq 0 ]]
  [[ $output = "Hello, World!" ]]
}

I run it with bats hello_world_test.sh, and the console output is this:

 ✗ Say Hi!
   (in test file hello_world_test.sh, line 8)
     `[[ $status -eq 0 ]]' failed

In my opinion it would be very nice if the test described WHY it has failed.

For the example above, I would think a good error message would be something like, "Expected output to be "Hello, World!", but received, "Hello Worldy!"

Thanks! ❤️

stefanlasiewski commented 4 years ago

FYI, this project is no longer maintained. Please give it's successor a try:

https://github.com/bats-core/bats-core