lehmannro / assert.sh

bash unit testing framework
GNU Lesser General Public License v3.0
487 stars 57 forks source link

Contributing assert-extras.sh #13

Open dansoton opened 9 years ago

dansoton commented 9 years ago

Further to my comment in Issue #10 I've created a contender for what assert-extras.sh may look like, at least as a starting point. I've also backed it with a new test-extras.sh file for regression tests.

I think it could be useful to accept so that people could opt into a broader set of assertions by sourcing assert-extras.sh as well as assert.sh. Those not wanting to use these would be unaffected as they wouldn't source this new file.

Also see the commit which updates assert.sh's _assert_fail() function to return an rc of 1 so that all assertions will return an rc 1 if the assertion fails which allows a program to check if an assertion has failed without having to wrap in a '_clean' and 'assert_end' block like the current tests appear to do.

lehmannro commented 8 years ago

This totally slipped my inbox. If I ever find the time I'm going to cherry-pick the changes to assert.sh core. Did you ever put the extras somewhere else, so we could distribute this as an add-on? I'd like to keep the core repository relatively small and have helpers etc. somewhere else.

asbjornu commented 8 years ago

@lehmannro I'd say that having methods such as assert_startswith is not exactly "extra", but rather basic functionality in any assertion framework. I was unable to perform any meaningful assertions without the functions provided by this PR's assert-extras.sh.

I would at least love to have easy access to assert-extras.sh and think the changes to assert.sh contribtued here are ace. @dansoton can you perhaps dissect this PR into two separate ones; one for the changes to assert.sh and one for assert-extras.sh?