Fork me on GitHub
#testing
<
2021-11-06
>
fabrao18:11:47

Hello, Is there any way to configure dynamicaly a fixture? How do I pass information to use-fixtures to configure a file that will be used?

thom21:11:18

Make a function that returns a function. So you call (use-fixture :each (my-fixture config)) etc

mauricio.szabo14:11:14

Or don't use fixtures at all. Seriously, I never use fixtures because they are quite unpredictable in some situations - in general, I use a macro around the test with a try...finally for teardowns. Makes everything easier 🙂

👍 1
thom14:11:59

How do you find them unpredictable? They're certainly a bit suboptimal as implemented in Clojure just because they don't interact with ‘testing’ blocks in any useful way, but they've generally done what I expect, at least.

mauricio.szabo14:11:36

In async ClojureScript contexts, they behave strangely, for example; you can't evaluate test fragments like testing and make fixtures run; you're forced to use run-test or similar code (and these don't interact that well with ClojureScript also), and other small problems...

mauricio.szabo14:11:57

For Clojure, they do generally work, with the exception of losing the ability to evaluate test fragments and being forced to work with run-test and friends. But in ClojureScript, when you have async tests, most of the "core utilities to woth with tests" like with-redefs for example break down hard 😞

👆 1
thom15:11:18

Gotcha, interesting