Fork me on GitHub
#leiningen
<
2016-09-27
>
tengstrand12:09:12

I can run all my tests in my test namespace from within my IDE (Cursive), but I can’t run ‘lein test’. When I do that, it seems like lein tries to load and execute all namespaces, even though I exclude the problematic parts (the function that tries to connect to a local database) from my test namespace. Is there any work around? I can redefine the function that connects to the local database, but that feels like a hack.

donaldball14:09:01

Many consider it poor form to execute side-effecting code when requiring a namespace

donaldball14:09:59

They would advocate rolling up your startup stuff either into a namespace not (indirectly) required by your tests, and/or require e.g. an init! fn call to do all the startup stuff

donaldball14:09:54

Others might say make the function that connects to the local database context-aware, so it connects to the right database depending on if it’s running in a test environment or not