kward / shunit2

shUnit2 is a xUnit based unit test framework for Bourne based shell scripts.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

dangerous! shunit2 false positive when test includes syntax error

eedwards-sk opened this issue · comments

2.1.7

Note that it never actually runs the assertion. It seems to bail on the syntax error, and stop the rest of the function from executing, but then shunit2 reports it as a success.

This is bad since it will hide failing tests.

#!/usr/bin/env bash

thing_with_syntax_error() {
  ${!#3442} -334 a$@2[1]
}

test_thing() {
  thing_with_syntax_error
  
  assertEquals '' 'true' 'false'
}

source shunit2

output:

test_thing
../tests/ut/list/add.test: line 4: ${!#3442}: bad substitution

Ran �[1;36m1�[0m test.

�[1;32mOK�[0m
PASS tests/ut/list/add.test (exit status: 0)