slagyr / speclj

pronounced "speckle": a TDD/BDD framework for Clojure.
MIT License
459 stars 58 forks source link

consider using standard exception type for assertion failures #43

Closed maxbrunsfeld closed 10 years ago

maxbrunsfeld commented 11 years ago

Thanks for building this! What are your thoughts on making should= et al. throw the standard exception type AssertionError, rather than your own? It seems like that would facilitate writing interchangeable assertion libraries that work with speclj.

slagyr commented 11 years ago

You're welcome. I'm open to the option. What assertion libraries are out there? Do they all use AssertionError as the base exception?

Micah

On Apr 19, 2013, at 12:13 AM, maxbrunsfeld notifications@github.com wrote:

Thanks for building this! What are your thoughts on making should= et al throw the standard exception type AssertionError, rather than your own? It seems like that would facilitate writing interchangeable assertion libraries that work with speclj.

— Reply to this email directly or view it on GitHub.

maxbrunsfeld commented 11 years ago

Well right now as far as I know there's just clojure.core/assert, which throws an AssertionError.

I'd like to be able to add matchers to my speclj test suite as easily as possible (and possibly make them available as a specialized matcher library). I could of course just (:import specljs.SpecFailure), but I feel it'd be nicer to just use what's in clojure.core.

Also, someone might want to write a library that supports another syntax for making assertions, and it'd be great if they could be dropped into a speclj test suite. In that case too, using AssertionError would make it easier.

slagyr commented 11 years ago

Included in 2.6.0

trptcolin commented 11 years ago

We may need to revisit this. I didn't see any problem at the time, but now there doesn't appear to be any way to exercise code like this without failing a spec.

(defn get-valid-input [input]
  (assert (valid? input))
  input)

The assert's behavior can't be verified with a should-throw test since should-throw now re-throws any AssertionError. I'm not seeing a clear way to fix it, unfortunately.

slagyr commented 10 years ago

SpecFailure has been restored.

slagyr commented 10 years ago

2.8.1 contains the restoration of SpecFailure.