Fork me on GitHub

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.


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


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


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