lein test with command-line args?

813 views
Skip to first unread message

AndyK

unread,
Nov 7, 2011, 5:14:36 PM11/7/11
to Clojure
Is it possible to pass command-line arguments to tests using
leiningen? Looking for ways to control the way that tests are run
using lein test by passing in switches (e.g. which environment it runs
against, which tests run, etc). One workaround that occurs to me is to
use lein run where run calls run-tests directly, but that seems
hacktacular.

More generally, how would you set parameters for run-tests using
command-line args or function args?

Phil Hagelberg

unread,
Nov 7, 2011, 5:17:19 PM11/7/11
to clo...@googlegroups.com
On Mon, Nov 7, 2011 at 2:14 PM, AndyK <andy....@gmail.com> wrote:
> Is it possible to pass command-line arguments to tests using
> leiningen? Looking for ways to control the way that tests are run
> using lein test by passing in switches (e.g. which environment it runs
> against, which tests run, etc). One workaround that occurs to me is to
> use lein run where run calls run-tests directly, but that seems
> hacktacular.

Have you tried using test selectors? "lein help tutorial" explains how
they work.

-Phil

AndyK

unread,
Nov 8, 2011, 1:16:59 PM11/8/11
to Clojure
Those are cool - thank you for bringing them to my attention

They don't appear to address the issue of setting up environment data.
For example, lein test :development -vs- lein test :staging where
different configs are loaded for :development or :staging (ex:
database, web endpoints).

On Nov 7, 5:17 pm, Phil Hagelberg <p...@hagelb.org> wrote:
> On Mon, Nov 7, 2011 at 2:14 PM, AndyK <andy.kri...@gmail.com> wrote:
> > Is it possible to pass command-line arguments to tests using
> > leiningen? Looking for ways to control the way that tests are run
> > usingleintestby passing in switches (e.g. which environment it runs
> > against, which tests run, etc). One workaround that occurs to me is to
> > useleinrun where run calls run-tests directly, but that seems
> > hacktacular.
>
> Have you tried usingtestselectors? "leinhelp tutorial" explains how
> they work.
>
> -Phil

Phil Hagelberg

unread,
Nov 8, 2011, 1:22:29 PM11/8/11
to clo...@googlegroups.com
On Tue, Nov 8, 2011 at 10:16 AM, AndyK <andy....@gmail.com> wrote:
> Those are cool - thank you for bringing them to my attention
>
> They don't appear to address the issue of setting up environment data.
> For example, lein test :development -vs- lein test :staging where
> different configs are loaded for :development or :staging (ex:
> database, web endpoints).

OK, I see. I recommend using environment variables for that kind of
configuration.

-Phil

Reply all
Reply to author
Forward
0 new messages