Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

selectors for tests #28

Open
nha opened this issue Dec 10, 2016 · 3 comments
Open

selectors for tests #28

nha opened this issue Dec 10, 2016 · 3 comments

Comments

@nha
Copy link

nha commented Dec 10, 2016

From lein help test:

Run the project's tests.

Marking deftest or ns forms with metadata allows you to pick selectors to
specify a subset of your test suite to run:

   (deftest ^:integration network-heavy-test
     (is (= [1 2 3] (:numbers (network-operation)))))

Write the selectors in project.clj:

   :test-selectors {:default (complement :integration)
                    :integration :integration}

Arguments to this task will be considered test selectors if they are keywords,
otherwise arguments must be test namespaces or files to run. With no
arguments the :default test selector is used if present, otherwise all
tests are run. Test selector arguments must come after the list of namespaces.

A default :only test-selector is available to run select tests. For example,
`lein test :only leiningen.test.test/test-default-selector` only runs the
specified test. A default :all test-selector is available to run all tests.

Arguments: ([& tests])

It would be nice to have a :test-selector parameter in boot test as well (it allows filtering namespaces at the moment, but not individual tests as far as I know).

@alehatsman
Copy link

any plans on this?

@alehatsman
Copy link

alehatsman commented Oct 15, 2017

Hi, i found that i can emulate such feature by using "filters" configuration option.

(deftask integration-test
  "Runs integration tests"
  []
  (comp (environ :env 
                 {:http-port "9000"
                  :database-url "jdbc:postgresql://localhost:32768/test?user=postgres&password=postgres"})
        (test :filters #{'(-> % (meta) (:integration))})))

That interesting, now i am not sure should this functionality be in core or not. Because it is so easy to implement different strategies of what tests/namespaces you want to run tests on.

@akhudek
Copy link

akhudek commented May 18, 2019

I think the filters option actually filters functions, not namespaces. I was just trying to use it to exclude namespaces and while debugging noticed that it gets evaluated for every symbol in every namespace. Returning false doesn't stop the evaluation, and even if you return false for every symbol in a namespace it still prints "Testing namespace.foo".

Perhaps the documentation should be improved to make it clear that this doesn't filter namespaces, but rather functions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants