Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception in fixtures produces cryptic runs #134

Open
laurentsenta opened this issue May 6, 2017 · 4 comments
Open

Exception in fixtures produces cryptic runs #134

laurentsenta opened this issue May 6, 2017 · 4 comments

Comments

@laurentsenta
Copy link

laurentsenta commented May 6, 2017

When a fixture throws, it looks like doo is crashed or miscompiling.

I'd expect the library to catch the exception and explicitly describe "fixture threw, skipped this module". This would be shown as an error in the final reporting instead of looking like doo stopped.

;; ======================================================================
;; Testing with Phantom:


Testing konserve-firebase.some-test

FAIL in (some-b) (:)
expected: (= (+ 1 2) 2)
  actual: (not (= 3 2))

Testing konserve-firebase.core-test
WARNING: doo's init function was not set
#object[TypeError TypeError: undefined is not an object (evaluating 'f.cljs$lang$maxFixedArity')]
(ns konserve-firebase.core-test
   ...)

(use-fixtures :once
  {:before
   (fn []
     (throwing-code))
   :after
   (fn [])})

(deftest some-test
  (is false))

This makes the test fragile, a small change deep in a fixture setup/teardown fixture breaks the tests without much feedback.

@laurentsenta
Copy link
Author

Example repo:
https://github.com/lsenta/budb/tree/doo-demo-134

run make test-cljs there, you'll see the doo not set error.

@MatthewDarling
Copy link
Contributor

I guess to resolve this, there would need to be some intermediate exception handling which says "here's the error which happened in the tests for this namespace".

For those more familiar with the code: Is there a specific part of doo which is basically saying, "run one individual test" or "run the tests for this namespace"? Or is that delegated to an underlying library?

@bensu
Copy link
Owner

bensu commented Sep 26, 2017

That is delegated to the underlying library:

https://github.com/bensu/doo/blob/master/library/src/doo/runner.clj

The only decision that doo makes is to either run all ns or the selected ns. I think your latest PR might show a better error message for this case.

@MatthewDarling
Copy link
Contributor

Hmm, it seems like clojure.test doesn't have a good way to handle this either. Leiningen actually adds an error message for exception in test fixtures. They replace clojure.test/test-ns with a version that catches exceptions and reports them.

I guess it would fall on doo to provide that same additional behaviour to cljs.test. Leiningen has started to warn people against using its testing wrappers, though, so maybe not the best approach to emulate...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants