Looking for suggestions on strategies to write clojure.test tests for testing a system that uses environment variables, where each test could use a different value of the environment variables. Assume I cannot modify the system under test. Assume that the system uses which depends on CLASSPATH and that each test might want to have a different CLASSPATH. Assume the system also uses other env vars. Ideally, some way to have a with-env-vars that I can use inside a test. Or is this just a bad idea, and I should consider some other approach. Thanks.
I’m not sure if you can add libraries, but you can use https://github.com/juxt/aero to control environment variables based on the environment through profiles
Thanks for the suggestion. I am familiar with aero. The issue is that in a standard clojure.test test run, there is just one Clojure and Java process that runs all tests. And so, the environment is the same for all the tests. What I want is to have a different environment for each test. I can think of several ways to achieve this, but none seem clean to me. The simplest is to use bb or some other tool to run multiple test processes, each with a different environment, and have each process just run a subset of the tests. I am hoping for a better way to achieve what I want.