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

Run tests by tasks #783

Open
reify-raman-adlakha opened this issue Jan 18, 2025 · 5 comments
Open

Run tests by tasks #783

reify-raman-adlakha opened this issue Jan 18, 2025 · 5 comments

Comments

@reify-raman-adlakha
Copy link

Not an issue but a suggestion.

Exercism Clojure track tests have metadata :task attached with values from 1 to n, each representing a task in the exercise. While working through tasks sequentially, I prefer running tests specific to the current task. Running these tests using :only (like lein test :only ns/test_function) is tedious since I must execute each test individually. I wanted a way to run all tests associated with a task at once.

After studying how test selectors work, I added a test-selector in project.clj. Now I can run all tests for a specific task—for example, task 2 —using lein test :task 2

Add the :task test-selector in any project that has tests defined with ^{:task 1} type markers.

I hope you find it useful.

(defproject annalyns-infiltration "0.1.0-SNAPSHOT"
    :description "annalyns-infiltration exercise."
    :url "https://github.com/exercism/clojure/tree/main/exercises/concept/annalyns-infiltration"
    :dependencies [[org.clojure/clojure "1.11.1"]]
    :test-selectors {;; Selects all tests with the :task metadata key matching the given value.                          
                     ;; usage
                     ;; lein test :task n ;; where n is the task number
                     :task (fn [m task]
                             (when-let [task-value (get m :task)]
                               (= task task-value)))})
Copy link
Contributor

Hello. Thanks for opening an issue on Exercism 🙂

At Exercism we use our Community Forum, not GitHub issues, as the primary place for discussion. That allows maintainers and contributors from across Exercism's ecosystem to discuss your problems/ideas/suggestions without them having to subscribe to hundreds of repositories.

This issue will be automatically closed. Please use this link to copy your GitHub Issue into a new topic on the forum, where we look forward to chatting with you!

If you're interested in learning more about this auto-responder, please read this blog post.

@ErikSchierboom
Copy link
Member

I like the idea. @tasxatzial what about you?

@tasxatzial
Copy link
Member

Yes, they posted this on discord and I redirected them here.

@tasxatzial
Copy link
Member

We can also do something similar for practice exercises. Run by function, for instance.

@ErikSchierboom
Copy link
Member

Great idea.

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