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

Add assertions for files and directories

ddidier opened this issue · comments

A very useful project, thank you.
Some new assertions to consider:

  • assertFileExists
  • assertFileDoesNotExist
  • assertFileContains
  • assertFileDoesNotContain
  • assertDirectoryExists
  • assertDirectoryDoesNotExist

See pull request #115

test supports many expressions. Why single these few out?

The recently added failFound and failNotFound might be what you're looking for:

[ -f want ] || failNotFound want
[ ! -f dont ] || failFound dont

grep -q needle /haystack || failNotFound ...

I didn't see this pattern, but I believe the ones I added are more readable (and I use them often).