Git Product home page Git Product logo

test-refresh's Introduction

Like many Clojure projects, this is stable and doesn't require active maintenance. There might not be recent commits but it is still used and maintained.

Build Status

test-refresh

This is a Clojure tool that notices when your source changes and then reloads your code and runs your clojure.test tests. It works with Leiningen and deps.edn based projects.

It also works with expectations clojure.test compatible syntax.

Features

  • Enables quick feedback cycles by automatically refreshing your code and running your tests.
  • Runs previously failing tests first, giving you feedback even quicker.
  • Built-in test-selector, :test-refresh/focus, that lets you narrow the scope of your testing without restarting test-refresh. A different selector can be overridden through configuration. See the sample project.clj or documentation in this README for more details.
  • Optionally only automatically runs tests in changed namespaces.
  • Can pass result of running your tests to a notification command of your choice.
  • Has built in Growl notification support.
  • Can be configured to only notify you on failures.
  • Times how long it takes to run your tests.
  • Can optionally suppress clojure.test's Testing namespace output. This is extremely useful in making test output with larger codebases readable again.
  • You can hit enter in terminal to force tests to rerun.
  • Supports clojure.test's custom reports.
  • Supports running your tests once! Useful for taking advantage of custom test reporters or quiet output in CI systems.
  • Has optional repl support for changing global state, such as timbre logging levels
  • Detects if your project uses circleci.test and uses that instead of clojure.test.
  • Leiningen only: Supports subset of Leiningen test selectors.

sample.project.clj show optional Leininen configuration. example.test-refresh.edn shows configuration options available to deps.edn based projects.

The sample configuration files and the rest of this documentation show how test-refresh can be used.

Usage

Leiningen based projects

See docs/leiningen.md.

deps.edn based projects

See docs/deps_edn.md.

Features

Any command line example here that is lein test-refresh :some-argument is only supported by Leiningen. deps.edn usage must be configured through .test-refresh.edn files.

Hit Enter to rerun tests

If you need to rerun your tests without changing a file then hit Enter when focused on a running test-refresh. This behavior will stop if test-refresh thinks it has read till the end of STDIN. This is usually caused by hitting ctrl-d, but also when a specific version of bash is invoked by test-refresh which can happen when running tests or notify commands.

Built-in test narrowing (test selector)

Have you ever been running all of your tests and then want to only focus on one? Instead of commenting out the others or quitting test-refresh and restarting with a test-selector you can add :test-refresh/focused true to your test(s) or namespace.

With the below code, only test-addition will run until the :test-refresh/focus marker is removed from it.

(deftest ^:test-refresh/focus test-addition
  (is (= 2 (+ 1 1))))

(deftest test-subtraction
  (is (= 0 (- 10 9 1))))

You can optionally specify a shorter flag by adding :focus-flag :your-flag to test-refresh's configuration.

Configuration Features

A sample.project.clj contains the definitive example of configuring test-refresh features. Configuration can appear in any file that Leiningen uses to merge into your project's configuration when running commands. Often test-refresh configuration is a personal preference and should be configured in your personal ~/.lein/profiles.clj.

Notifications

test-refresh supports specifying a notification command. This command is passed a short message after your tests have run. This command is configured through your project.clj or profiles.clj. For example, if you want to send OSX notifications using terminal-notifier then you would add the following to your project.clj or profiles.clj

:test-refresh {:notify-command ["terminal-notifier" "-title" "Tests" "-message"]}

test-refresh also has built-in Growl support. To receive Growl notifications run lein test-refresh :growl. This has been tested with modern (well, asof 2016) versions of Growl for OS X, Linux, and Windows. You can also always set this to true by setting :test-refresh {:growl true}}. An example can be found in the sample project.clj.

:notify-on-success is another available option. It can be used to turn off notifications when your tests are successful. Set :notify-on-success false to turn off success notifications. An example can be found in the sample project.clj.

Reduced terminal output

test-refresh can be configured to suppress clojure.test's Testing namespace output. Add :quiet true to your :test-refresh configuration map to suppress clojure.test's noisy output. This is particularly useful on codebases with a large number of test namespaces.

Only run changes in changed namespaces.

test-refresh can be configured to only automatically run tests in changed namespaces. This can be used to get even faster feedback since only tests where something has changed will be run. You can toggle this mode by adding a :changes-only true entry in your :test-refresh configuration or by passing it as a command line option lein test-refresh :changes-only.

If you are in this mode and want to run all your tests you can trigger them by hitting enter in the terminal where test-refresh is running.

Custom Clojure.test report

test-refresh can be configured to use a custom clojure.test output report. Add :report myreport.namespace/myreport to your :test-refresh configuration map to use your own reporter for clojure.test's output. An example can be found in the sample project.clj.

Running your tests once

At first this seems like a weird feature for a refreshing test runner to support but because of the other features test-refresh supports, such as custom test runners, being able to just run tests once can be useful. See this pull request for discussion.

You can either configure this option in your project.clj (or profiles.clj) or pass it as a command line option. Check out sample.project.clj for an example of project configuration.

Using it at the command line looks like lein test-refresh :run-once.

Running with a REPL

test-refresh can be run with :with-repl which will start up a repl that you can interact with in between test runs. The main reason for this option is that sometimes you want to affect global state in your application. An example is when you see a test failure, you can call (taoensso.timbre/set-level! :debug) and see more information.

See this pull request for details.

Running in a REPL

test-refresh supports running in a repl. This was done to support running in Cursive's repl so users could click and navigate to source.

To use this feature, add test-refresh as a project dependency instead of as a plugin. Then open your repl and do the following

user=> (require 'com.jakemccrary.test-refresh)
nil
user=> (com.jakemccrary.test-refresh/run-in-repl "test")
*********************************************
*************** Running tests ***************

The tests will run until you kill the evaluation with ctrl-c.

This feature is one I never use myself. I'd consider it experimental. In my very limited testing I've had some weird behavior where I couldn't get it to stop running. I'm putting it out there though so others can use it.

Contributing

I encourage pull requests. If you're making a large change it is probably a good idea to create an issue and run it by me first. If you open a pull request you should expect me to review the code and potentially suggest improvements.

Working on test-refresh can be a bit tricky. Despite being a tool to enhance testing it has very few tests itself. As a result its sort of a pain to work on. My typical work flow is outlined below. I encourage you to do the following as well (or better yet, add some useful tests!).

  1. Open two terminals, one in the ./test-refresh directory and one in ./lein2.
  2. In ./test-refresh run lein install to put a version built from your local test-refresh checkout into your ~/.m2 directory.
  3. The project in ./lein2 is setup to use whatever version is specified in ./test-refresh/project.clj. As a result it will use the recently lein installed version from the above step. Use the project in ./lein2 to test out your local version of test-refresh. Toggle settings in ./lein/project.clj to test various features. Make tests fail and pass.
  4. Make your changes to the project in ./test-refresh and lein install.
  5. Repeat manual testing in ./lein2. Add sample code or configuration to ./lein2 project to show your changes.

Its a bit painful but it works. If there were more active changes happening to the project I'd invest the time to figure out how to test it but given the stability of test-refresh I haven't bothered. They would be a welcome addition.

Latest version & Change log

The latest version is the highest non-snapshot version found in CHANGES.md or whatever the below images says (sometimes image doesn't seem to load).

Leiningen

Latest version

deps.edn

Latest version

Compatibility

lein-test-refresh has been tested to work with Clojure 1.5.1, 1.6, and 1.7, 1.8, 1.9 with Leiningen 2.3+.

Because of tools.namespace changes test-refresh requires that your project use Clojure >= 1.3.0. If your project also depends on a version of tools.namespace < 0.2.1 you may see occasional exceptions.

Leiningen 1.0

If you are using Leiningen 1 this project is definitely broken starting on lein-test-refresh version 0.21.0. Try using 0.20.0 or earlier. These versions were not explicitly tested with Leiningen 1 but they probably work. Leiningen 1 is not officially supported.

License

Copyright (C) Jake McCrary

Distributed under the Eclipse Public License, the same as Clojure.

test-refresh's People

Contributors

awkay avatar bagl avatar benrady avatar bitdeli-chef avatar cdorrat avatar crowbrammer avatar devn avatar donbonifacio avatar ikitommi avatar jakemcc avatar jdslavin avatar jell avatar lbradstreet avatar minhtuannguyen avatar mynomoto avatar nenadalm avatar timothypratley avatar tobias avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

test-refresh's Issues

Can't use user specified notification command

I'm trying to use the notify-command option but, due to the way terminal-notifier (and many other command line tools) work, having the last argument being a series of words separated by spaces causes the command to miss most of it. That is terminal-notifier -message Passed All Tests only shows "Passed" while terminal-notifier "Passed All Tests" shows the full message.

I had to create a small bash file to notify with this format:

#!/bin/bash
terminal-notifier -title "Engine Server Tests" -message "$*"

Maybe the message could be wrapped in double quotes?
Or be in a variable that can be used as preferred in the notification command?

Specs are not reloaded when run through compojure-api

With the project defined below, changes to my spec does not affect outcome of tests. You could change from string? to keyword? and test still passes.

When running specs directly on functions and instrumenting them, refreshing works. The issue only applies to specs like the ones below, referenced through compojure-api.

I realize this is likely to be an issue with either my code or with compojure-api. So please disregard or close if you think this is outside the scope of lein-test-refresh.

project.clj

(defproject proj "0.1.0-SNAPSHOT"
  :dependencies [[org.clojure/clojure "1.9.0-alpha17"]
                 [metosin/compojure-api "2.0.0-alpha7"]
                 [metosin/spec-tools "0.3.0"]
                 [ring/ring-mock "0.3.1"]
                 [ring/ring-json "0.5.0-beta1"]]
  :plugins [[com.jakemccrary/lein-test-refresh "0.20.0"]]
  :source-paths ["src"]
  :test-paths ["test"]
)

Source

(ns dings.core
  (:require [clojure.spec.alpha :as s]
            [compojure.api.sweet :as sweet :refer [api context GET POST PUT]]
            [ring.util.http-response :as response]
            [spec-tools.spec :as spec]))

(s/def ::fmu-list (s/coll-of string?))

(defn api-routes []
  (api
    {:coercion :spec}
    (context "/" []
      (GET "/allfmus" []
        :summary "All of them"
        :return ::fmu-list
        (response/ok ["one" "two"])))))

Test source

(ns dings.core-test
  (:require [clojure.test :refer :all]
            [dings.core :as core]
            [ring.mock.request :as mock]
            [ring.middleware.json :refer [wrap-json-response]]
            [cheshire.core :as cheshire]))

(defn parse-body [body]
  (cheshire/parse-string (slurp body) true))

(defn routes []
  (-> (core/api-routes)
      wrap-json-response))

(deftest fmus
  (testing "All FMUS work and correspond to spec"
    (let [response ((routes) (mock/request :get "/allfmus"))]
      (is (= ["one" "two"] (-> response :body parse-body))))))

more built in notification options

hi.

there is a :growl option, it would be nice to also have :terminal-notifier option out of the box.

thanks for writing this plugin!
PR

Could not find artifact lein-test-refresh

I tried to use this plugin. I tried following the installation instructions by putting the plugin in my profiles.clj file in my home directory. When I call lein deps, it cannot find the jar. I'm sure I'm doing something obviously wrong, but I checked it over and tried looking for the jar in the maven and clojars repositories and didn't see it there either. Do you know what I am doing wrong?

ryantm@ryantm0j132 ~ (master)$ cat .lein/profiles.clj 
cat .lein/profiles.clj 
{:user {:plugins [[lein-test-refresh "0.1.2"]]}}
ryantm@ryantm0j132 ~ (master)$ lein deps
lein deps
Could not find artifact lein-test-refresh:lein-test-refresh:jar:0.1.2 in central (http://repo1.maven.org/maven2/)
Could not find artifact lein-test-refresh:lein-test-refresh:jar:0.1.2 in clojars (https://clojars.org/repo/)
This could be due to a typo in :dependencies or network issues.
If you are behind a proxy, try setting the 'http_proxy' environment variable.
ryantm@ryantm0j132 ~ (master)$ 

Supporting clojure.test/with-test

Would it be possible to extend lein-test-refresh to support the clojure.test/with-test macro?

Basically, Iโ€™d like to auto run tests defined in this way:

(test/with-test
  (defn hello [name]
    (str "Hello, " name))
  (is (= (hello "Brian") "Hello, Brian"))
  (is (= (hello nil) "Hello, ")))

Right now, these are not loaded by lein-test-refresh because they are attached as meta data to the functions.

REPL

Is there a way to have this running on a repl? At this moment I have lein test-refresh running and also lein repl running. Can I launch test-refresh on the repl and use only one instance?

Clearing screen before each test run

Would an option to clear the screen before each test run be considered?

I'm fairly new to Clojure but would be happy to have a go at a PR, if so...

Persisting slow state between reloads

Thought worth mentioning: I've managed to keep my slow-to-setup pieces of state from annoying reloading by moving it to separate NS and marking it with

(clojure.tools.namespace.repl/disable-reload!)

Assertions x tests count

I'm getting:
Failed 32 of 12 tests.

Where 32 is the number of assertions failed and 12 is the number of tests.
Would you like a pr to fix this?

Tests as cljc

Hello,

I migrated a project to cljc, and now test-refresh don't load any tests. Note that lein test also doesn't load them automatically, don't know if has anything to do with it. I'm still able to run all tests by requiring namespaces and with a test-runner.

`:notify-command` should be shaped like `:dependencies`

Because it is a single vector when Leiningen merges multiple :notify-command values you end up with multiple commands smushed together. The value of :notify-command should be a vector of vectors. This would allow multiple :notify-commands to be specified.

ANSI color for test run results

It would be awesome if there was a way to specify colorized output of the test runs.

The most import would be to make the failures RED and the passes GREEN with the final status message (Passed all tests or Failed 1 of 1 assertions) being RED or GREEN depending on which status it is.

lein test-refresh doesn't run any tests

Hello!

I realize you mostly hear from people when they have something to complain about so let me just start this off on a positive note and let you know that I love your plugin. Development is a lot more enjoyable with instantaneous feedback!

Now, on this one project I get this output from test-refresh:

Ran 0 tests containing 0 assertions.
0 failures, 0 errors.

and it stubbornly sticks to that story.

The output from lein test is a lot more interesting:

Ran 12 tests containing 116 assertions.
0 failures, 0 errors.

AFAIK there's nothing special about this project, but then I'm not sure what might cause this. I'm running 0.9.0 of lein-test-refresh

$ lein --version
Leiningen 2.5.1 on Java 1.8.0_45 OpenJDK 64-Bit Server VM

StackOverflowError

Hi - I'm loving test-refresh and use it all the time. Unfortunately, I've found a corner case that seems to result in a SOE. The stacktrace looks like:

Ran 97 tests containing 1087 assertions.
0 failures, 0 errors.
Exception in thread "main" java.lang.StackOverflowError, compiling:(/tmp/form-init2179314932373391560.clj:1:73)
	at clojure.lang.Compiler.load(Compiler.java:7391)
	at clojure.lang.Compiler.loadFile(Compiler.java:7317)
	at clojure.main$load_script.invokeStatic(main.clj:275)
	at clojure.main$init_opt.invokeStatic(main.clj:277)
	at clojure.main$init_opt.invoke(main.clj:277)
	at clojure.main$initialize.invokeStatic(main.clj:308)
	at clojure.main$null_opt.invokeStatic(main.clj:342)
	at clojure.main$null_opt.invoke(main.clj:339)
	at clojure.main$main.invokeStatic(main.clj:421)
	at clojure.main$main.doInvoke(main.clj:384)
	at clojure.lang.RestFn.invoke(RestFn.java:421)
	at clojure.lang.Var.invoke(Var.java:383)
	at clojure.lang.AFn.applyToHelper(AFn.java:156)
	at clojure.lang.Var.applyTo(Var.java:700)
	at clojure.main.main(main.java:37)
Caused by: java.lang.StackOverflowError
	at com.jakemccrary.test_refresh$run_tests.invoke(test_refresh.clj)
	at com.jakemccrary.test_refresh$run_tests.invokeStatic(test_refresh.clj:162)
	at com.jakemccrary.test_refresh$run_tests.invoke(test_refresh.clj:156)
	at com.jakemccrary.test_refresh$run_tests.invokeStatic(test_refresh.clj:162)

I have a test function that looks like this:

  (is (every? t/truthy? (forv [lb (range 0 4)
                               ub (range lb 4) ]
                          (= (t/rng lb ub) (range lb ub)))))

In order to force it to fail, I change "ub" to "9" at the end:

  (is (every? t/truthy? (forv [lb (range 0 4)
                               ub (range lb 4) ]
                          (= (t/rng lb ub) (range lb 9)))))

test-refresh reports the failure as expected.

Testing tst.tupelo.core
FAIL in (t-rng) (core.cljc:547)
expected: (every? t/truthy? (forv [lb (range 0 4) ub (range lb 4)] (= (t/rng lb ub) (range lb 9))))
  actual: (not (every? #object[tupelo.core$truthy_QMARK_ 0x6873b40f "tupelo.core$truthy_QMARK_@6873b40f"] [false false false false false false false false false false]))

Then, when I change it back from "9" to "ub", I get an infinite loop that results in the SOE.

Any ideas?

Refresh stops when encountering a circular dependency

When I create a circular dependency during refactoring (more often than I'd like to admit), test-refresh just stops and I need to restart it completely. The stacktrace printed to the console looks something like this:

Exception in thread "main" java.lang.Exception: Circular dependency between ns.one and ns.two, compiling:(/private/var/folders/20/n648ws_s0qj1kpdjq_v5vtgc0000gn/T/form-init2751876959826785001.clj:1:125)
    at clojure.lang.Compiler.load(Compiler.java:7391)
    at clojure.lang.Compiler.loadFile(Compiler.java:7317)
    at clojure.main$load_script.invokeStatic(main.clj:275)
    at clojure.main$init_opt.invokeStatic(main.clj:277)
    at clojure.main$init_opt.invoke(main.clj:277)
    at clojure.main$initialize.invokeStatic(main.clj:308)
    at clojure.main$null_opt.invokeStatic(main.clj:342)
    at clojure.main$null_opt.invoke(main.clj:339)
    at clojure.main$main.invokeStatic(main.clj:421)
    at clojure.main$main.doInvoke(main.clj:384)
    at clojure.lang.RestFn.invoke(RestFn.java:421)
    at clojure.lang.Var.invoke(Var.java:383)
    at clojure.lang.AFn.applyToHelper(AFn.java:156)
    at clojure.lang.Var.applyTo(Var.java:700)
    at clojure.main.main(main.java:37)

When I start it up again the exception is more useful to help trace down the circular dependency and get it fixed.

Support for quickly focusing on a subset of tests.

Using :test-selectors is nice but it requires you to kill the currently running lein test-refresh and restart it with a test selector.

It would be great if you could focus your tests without leaving your editor and restarting lein test-refresh

Improved output

We have a lot of test namespaces. This is our partial output:

screen shot 2015-04-17 at 11 51 30

If the first namespace has an error, we will have to scroll that window to check it out. Suggestion: remove all the Testing clanhr.directory-api.models.utils outputs.

Sometimes could is not reloaded

Hello,

Sometimes we experience code not being reloaded. For example, we add a println somewhere and save. The console updates, showing that it detected the change, but no output is present. If we restart lein-test-refresh, the println shows up.

This also meas that we might have come testes failing but lein-test-refresh don't report it, forcing us to restart the process several times.

I can't replicate this. Is this a know issue? Is there a workaround? Can I provide some more info?

Thanks

fine-tuning the number of tests that get re-run

Hi,

I was wondering if fine-tuning the tests that get scheduled to run was on the roadmap. I have been running my test suite using

lein test-refresh :changes-only

And im finding myself have to go to great lengths to avoid including a namespace. For example, I have a queries file I use ubiquitously in all my tests for assertions. I'd like to somehow tell test-refresh to ignore certain tests even though the namespace is included in the test.

Many thanks!

I get this error when moving a test file with test-refresh running

Probably involves a similar fix to #53

java.lang.Exception: No namespace: fake_project.something-spec found
    at clojure.core$the_ns.invoke(core.clj:4008)
    at clojure.core$ns_publics.invoke(core.clj:4040)
    at com.jakemccrary.test_refresh$nses_selectors_match$iter__32253__32259$fn__32260.invoke(test_refresh.clj:113)
    at clojure.lang.LazySeq.sval(LazySeq.java:40)
    at clojure.lang.LazySeq.seq(LazySeq.java:56)
    at clojure.lang.RT.seq(RT.java:507)
    at clojure.lang.RT.nthFrom(RT.java:924)
    at clojure.lang.RT.nth(RT.java:883)
    at clojure.core$distinct$step__5073$fn__5074$fn__5076.invoke(core.clj:4820)
    at clojure.core$distinct$step__5073$fn__5074.invoke(core.clj:4820)
    at clojure.lang.LazySeq.sval(LazySeq.java:40)
    at clojure.lang.LazySeq.seq(LazySeq.java:49)
    at clojure.lang.RT.seq(RT.java:507)
    at clojure.core$seq__4128.invoke(core.clj:137)
    at clojure.core$map$fn__4553.invoke(core.clj:2616)
    at clojure.lang.LazySeq.sval(LazySeq.java:40)
    at clojure.lang.LazySeq.seq(LazySeq.java:49)
    at clojure.lang.Cons.next(Cons.java:39)
    at clojure.lang.RT.next(RT.java:674)
    at clojure.core$next__4112.invoke(core.clj:64)
    at clojure.core$concat$cat__4217$fn__4218.invoke(core.clj:707)
    at clojure.lang.LazySeq.sval(LazySeq.java:40)
    at clojure.lang.LazySeq.seq(LazySeq.java:49)
    at clojure.lang.RT.seq(RT.java:507)
    at clojure.core$seq__4128.invoke(core.clj:137)
    at clojure.core$filter$fn__4580.invoke(core.clj:2679)
    at clojure.lang.LazySeq.sval(LazySeq.java:40)
    at clojure.lang.LazySeq.seq(LazySeq.java:56)
    at clojure.lang.RT.seq(RT.java:507)
    at clojure.core$seq__4128.invoke(core.clj:137)
    at com.jakemccrary.test_refresh$suppress_unselected_tests$move_all_meta_BANG___32244.invoke(test_refresh.clj:103)
    at com.jakemccrary.test_refresh$suppress_unselected_tests.invoke(test_refresh.clj:105)
    at com.jakemccrary.test_refresh$run_selected_tests.invoke(test_refresh.clj:142)
    at com.jakemccrary.test_refresh$run_tests.invoke(test_refresh.clj:157)
    at com.jakemccrary.test_refresh$monitor_project$fn__32312.invoke(test_refresh.clj:239)
    at com.jakemccrary.test_refresh$monitor_project.invoke(test_refresh.clj:227)
    at user$eval32351.invoke(form-init8728850342479536222.clj:1)
    at clojure.lang.Compiler.eval(Compiler.java:6782)
    at clojure.lang.Compiler.eval(Compiler.java:6772)
    at clojure.lang.Compiler.load(Compiler.java:7227)
    at clojure.lang.Compiler.loadFile(Compiler.java:7165)
    at clojure.main$load_script.invoke(main.clj:275)
    at clojure.main$init_opt.invoke(main.clj:280)
    at clojure.main$initialize.invoke(main.clj:308)
    at clojure.main$null_opt.invoke(main.clj:343)
    at clojure.main$main.doInvoke(main.clj:421)
    at clojure.lang.RestFn.invoke(RestFn.java:421)
    at clojure.lang.Var.invoke(Var.java:383)
    at clojure.lang.AFn.applyToHelper(AFn.java:156)
    at clojure.lang.Var.applyTo(Var.java:700)
    at clojure.main.main(main.java:37)

FR: show failing test stack traces at the bottom

First - thanks for the tool!

Secondly, quickie has a really nice feature in that it shows the stack traces of failing tests at the bottom of the console. It would be great if lein-test-refresh did this.

As it stands I need to manually search for the FAIL error message which in a project with close to 10K unit tests and a whole bunch of logging isn't particularly fun ;).

Thanks!

java.lang.AssertionError: Assert failed: (vector? (:dependencies project [])) when running lein test-refresh

I'm using Leiningen 2.6.1 and lein-test-refresh 0.14.0 but running: lein test-refresh on my project yields:

Exception in thread "main" java.lang.AssertionError: Assert failed: (vector? (:dependencies project []))
    at leinjacker.deps$add_if_missing.invokeStatic(deps.clj:43)
    at leinjacker.deps$add_if_missing.invoke(deps.clj:43)
    at leiningen.test_refresh$add_deps.invokeStatic(test_refresh.clj:10)
    at leiningen.test_refresh$add_deps.invoke(test_refresh.clj:8)
    at leiningen.test_refresh$test_refresh.invokeStatic(test_refresh.clj:51)
    at leiningen.test_refresh$test_refresh.doInvoke(test_refresh.clj:39)
    at clojure.lang.RestFn.invoke(RestFn.java:410)
    at clojure.lang.Var.invoke(Var.java:379)
    at clojure.lang.AFn.applyToHelper(AFn.java:154)
    at clojure.lang.Var.applyTo(Var.java:700)
    at clojure.core$apply.invokeStatic(core.clj:648)
    at clojure.core$apply.invoke(core.clj:641)
    at leiningen.core.main$partial_task$fn__5829.doInvoke(main.clj:272)
    at clojure.lang.RestFn.invoke(RestFn.java:410)
    at clojure.lang.AFn.applyToHelper(AFn.java:154)
    at clojure.lang.RestFn.applyTo(RestFn.java:132)
    at clojure.lang.AFunction$1.doInvoke(AFunction.java:29)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.core$apply.invokeStatic(core.clj:648)
    at clojure.core$apply.invoke(core.clj:641)
    at leiningen.core.main$apply_task.invokeStatic(main.clj:322)
    at leiningen.core.main$apply_task.invoke(main.clj:308)
    at leiningen.core.main$resolve_and_apply.invokeStatic(main.clj:328)
    at leiningen.core.main$resolve_and_apply.invoke(main.clj:324)
    at leiningen.core.main$_main$fn__5895.invoke(main.clj:401)
    at leiningen.core.main$_main.invokeStatic(main.clj:394)
    at leiningen.core.main$_main.doInvoke(main.clj:391)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at clojure.lang.Var.invoke(Var.java:379)
    at clojure.lang.AFn.applyToHelper(AFn.java:154)
    at clojure.lang.Var.applyTo(Var.java:700)
    at clojure.core$apply.invokeStatic(core.clj:646)
    at clojure.main$main_opt.invokeStatic(main.clj:314)
    at clojure.main$main_opt.invoke(main.clj:310)
    at clojure.main$main.invokeStatic(main.clj:421)
    at clojure.main$main.doInvoke(main.clj:384)
    at clojure.lang.RestFn.invoke(RestFn.java:436)
    at clojure.lang.Var.invoke(Var.java:388)
    at clojure.lang.AFn.applyToHelper(AFn.java:160)
    at clojure.lang.Var.applyTo(Var.java:700)
    at clojure.main.main(main.java:37)

Just running lein test works fine.

test-refresh fails to start when project.clj has managed dependencies

The problem happens when project.clj has a managed dependency, like [clj-time]. If the dep is changed to non-managed [clj-time "0.14.0"] then everything works.

I have made a sample project that demonstrates the problem at https://github.com/jarppe/lein-test-refresh-issue

What version of lein-test-refresh?
0.20.0

What version of Leiningen?
2.7.1

Can you recreate the issue with a minimal project?
https://github.com/jarppe/lein-test-refresh-issue

scan-for-changes crashes on: "Unparsable namespace form: []"

When I have test-refresh open and I somehow save a file with a [] in its requires it causes this crash.
Which I causes me to have to restart test-refresh.

My guess is that a try-catch around src/com/jakemccrary/test_refresh.clj#L18 should help, but I'm not sure what should be returned.

I should have time to fix this sometime this week, but I figured I would put this out there until then.

user=> Exception in thread "main" java.lang.IllegalArgumentException: "Unparsable namespace form:" [], compiling:(/private/var/folders/p2/_mbs7hfj0fs6q74xqxlp4ykm0000gp/T/form-init6939121690210612328.clj:1:125)
    at clojure.lang.Compiler.load(Compiler.java:7239)
    at clojure.lang.Compiler.loadFile(Compiler.java:7165)
    ...
    at clojure.main.main(main.java:37)
Caused by: java.lang.IllegalArgumentException: "Unparsable namespace form:" []
    at clojure.tools.namespace.parse$deps_from_libspec.invoke(parse.clj:86)
    at clojure.tools.namespace.parse$deps_from_ns_form$fn__326.invoke(parse.clj:91)
        ...
    at clojure.tools.namespace.parse$deps_from_ns_decl.invoke(parse.clj:98)
    at clojure.tools.namespace.file$files_and_deps$fn__339.invoke(file.clj:39)
        ...
    at clojure.tools.namespace.file$files_and_deps.invoke(file.clj:37)
    at clojure.tools.namespace.file$add_files.invoke(file.clj:53)
    at clojure.tools.namespace.dir$update_files.invoke(dir.clj:40)
    at clojure.tools.namespace.dir$scan.doInvoke(dir.clj:62)
    at clojure.lang.RestFn.invoke(RestFn.java:410)
    at com.jakemccrary.test_refresh$scan_for_changes.invoke(test_refresh.clj:18)
    at com.jakemccrary.test_refresh$monitor_project.invoke(test_refresh.clj:225)
        ...
    ... 11 more

Need to respect :source-paths and :test-paths from project.clj

lein-test-refresh version 0.19.0
Lein version: Leiningen 2.7.1 on Java 1.8.0_111
Clojure 1.8.0

lein-test-refresh seems to recursively load all *.clj files instead of just those found on :source-paths and :test-paths from project.clj. This causes clashes when files that are not supposed to be in the build are attempted to be loaded/compiled.

"Problem communicating with Growl"

I am getting the following error when trying to set up notifications:
Problem communicating with growl, exception: Connection refused

This happens when i run lein test-refresh :growl from the command line as well as when putting :test-refresh {:growl true} into my project.clj. Running on Mac OSX 10.10.5, Leiningen Version is 2.5.3, Java 1.8.0. lein-test-refresh is at version 0.12.0.

When issuing Ctl+D on terminal it goes spinning

From a fresh install of leiningen, a default project and version 0.5.0 of leon-test-refresh,
when I do

$ lein test-refresh
Java HotSpot(TM) Client VM warning: TieredCompilation is disabled in this release.
Java HotSpot(TM) Client VM warning: TieredCompilation is disabled in this release.
*********************************************
*************** Running tests ***************
:reloading (app.core app.core-test)

Testing app.core-test

FAIL in (a-test) (core_test.clj:7)
FIXME, I fail.
expected: (= 0 1)
  actual: (not (= 0 1))

Ran 1 tests containing 1 assertions.
1 failures, 0 errors.

Failed 1 of 1 assertions
Finished at 10:46:56.598 (run time: 0.110s)

Then sending Ctl+d in the terminal makes lein-test-refresh execute tests in a continuous loop:

reloading ()

Testing app.core-test

FAIL in (a-test) (core_test.clj:7)
FIXME, I fail.
expected: (= 0 1)
  actual: (not (= 0 1))

Ran 1 tests containing 1 assertions.
1 failures, 0 errors.

Failed 1 of 1 assertions
Finished at 10:48:16.235 (run time: 0.014s)
*********************************************
*************** Running tests ***************
:reloading ()

Testing app.core-test

FAIL in (a-test) (core_test.clj:7)
FIXME, I fail.
expected: (= 0 1)
  actual: (not (= 0 1))

Ran 1 tests containing 1 assertions.
1 failures, 0 errors.

Failed 1 of 1 assertions
Finished at 10:48:16.453 (run time: 0.016s)
*********************************************
*************** Running tests ***************
:reloading ()

Testing app.core-test

FAIL in (a-test) (core_test.clj:7)
FIXME, I fail.
expected: (= 0 1)
  actual: (not (= 0 1))

Ran 1 tests containing 1 assertions.
1 failures, 0 errors.

Failed 1 of 1 assertions
Finished at 10:48:16.659 (run time: 0.005s)
*********************************************
*************** Running tests ***************
:reloading ()

Testing app.core-test

FAIL in (a-test) (core_test.clj:7)
FIXME, I fail.
expected: (= 0 1)
  actual: (not (= 0 1))

Ran 1 tests containing 1 assertions.
1 failures, 0 errors.

Failed 1 of 1 assertions
Finished at 10:48:16.870 (run time: 0.007s)
*********************************************
*************** Running tests ***************
:reloading ()

Testing app.core-test

FAIL in (a-test) (core_test.clj:7)
FIXME, I fail.
expected: (= 0 1)
  actual: (not (= 0 1))

Ran 1 tests containing 1 assertions.
1 failures, 0 errors.

Failed 1 of 1 assertions
Finished at 10:48:17.089 (run time: 0.008s)
*********************************************
*************** Running tests ***************
:reloading ()

Testing app.core-test

FAIL in (a-test) (core_test.clj:7)
FIXME, I fail.
expected: (= 0 1)
  actual: (not (= 0 1))

Ran 1 tests containing 1 assertions.
1 failures, 0 errors.

Failed 1 of 1 assertions
Finished at 10:48:17.296 (run time: 0.006s)
*********************************************
*************** Running tests ***************
:reloading ()

Testing app.core-test

FAIL in (a-test) (core_test.clj:7)
FIXME, I fail.
expected: (= 0 1)
  actual: (not (= 0 1))

Ran 1 tests containing 1 assertions.
1 failures, 0 errors.

Failed 1 of 1 assertions
Finished at 10:48:17.512 (run time: 0.006s)
*********************************************
*************** Running tests ***************
:reloading ()

Testing app.core-test

FAIL in (a-test) (core_test.clj:7)
FIXME, I fail.
expected: (= 0 1)
  actual: (not (= 0 1))

Ran 1 tests containing 1 assertions.
1 failures, 0 errors.

Failed 1 of 1 assertions
Finished at 10:48:17.723 (run time: 0.009s)
*********************************************
*************** Running tests ***************
:reloading ()

Testing app.core-test

FAIL in (a-test) (core_test.clj:7)
FIXME, I fail.
expected: (= 0 1)
  actual: (not (= 0 1))

Ran 1 tests containing 1 assertions.
1 failures, 0 errors.

Failed 1 of 1 assertions
Finished at 10:48:17.935 (run time: 0.011s)
*********************************************
*************** Running tests ***************
:reloading ()

Testing app.core-test

FAIL in (a-test) (core_test.clj:7)
FIXME, I fail.
expected: (= 0 1)
  actual: (not (= 0 1))

Ran 1 tests containing 1 assertions.
1 failures, 0 errors.

Failed 1 of 1 assertions
Finished at 10:48:18.147 (run time: 0.010s)
*********************************************
*************** Running tests ***************
:reloading ()

Testing app.core-test

FAIL in (a-test) (core_test.clj:7)
FIXME, I fail.
expected: (= 0 1)
  actual: (not (= 0 1))

Ran 1 tests containing 1 assertions.
1 failures, 0 errors.

Failed 1 of 1 assertions
Finished at 10:48:18.362 (run time: 0.014s)
*********************************************
*************** Running tests ***************
:reloading ()

Testing app.core-test

FAIL in (a-test) (core_test.clj:7)
FIXME, I fail.
expected: (= 0 1)
  actual: (not (= 0 1))

Ran 1 tests containing 1 assertions.
1 failures, 0 errors.

Failed 1 of 1 assertions
Finished at 10:48:18.576 (run time: 0.011s)
*********************************************
*************** Running tests ***************
:reloading ()

Testing app.core-test

FAIL in (a-test) (core_test.clj:7)
FIXME, I fail.
expected: (= 0 1)
  actual: (not (

rerun just one namespace

Is there a way to run just one namespace worth of tests at the command line like you can with

lein test com.example.test-widgets

It would be nice if we could do

lein test-refresh com.example.test-widgets

and have the tests keep running for that namespace.

Does not find data_readers.clj

lein test-refresh does not find the data_readers.clj file while lein test works.

I suspect this is caused by the classpath root being incorrect. See https://clojure.org/reference/reader#_tagged_literals

Full error:

ERROR in (print-method-uri) (Var.java:43)
Uncaught exception, not in assertion.
expected: nil
  actual: java.lang.IllegalStateException: Attempting to call unbound fn: #'helios.util/to-uri
 at clojure.lang.Var$Unbound.throwArity (Var.java:43)
    clojure.lang.AFn.invoke (AFn.java:32)
    clojure.lang.Var.invoke (Var.java:379)
    clojure.lang.LispReader$CtorReader.readTagged (LispReader.java:1351)
    clojure.lang.LispReader$CtorReader.invoke (LispReader.java:1330)
    clojure.lang.LispReader$DispatchReader.invoke (LispReader.java:786)
    clojure.lang.LispReader.read (LispReader.java:265)
    clojure.lang.LispReader.readDelimitedList (LispReader.java:1302)
    clojure.lang.LispReader$MapReader.invoke (LispReader.java:1260)
    clojure.lang.LispReader.read (LispReader.java:265)
    clojure.lang.LispReader.read (LispReader.java:198)
    clojure.lang.LispReader.read (LispReader.java:187)
    clojure.lang.RT.readString (RT.java:1850)
    clojure.lang.RT.readString (RT.java:1845)
    clojure.core$read_string.invokeStatic (core.clj:3769)
    clojure.core$read_string.invoke (core.clj:3759)
    helios.util_test$fn__16615.invokeStatic (util_test.clj:105)
    helios.util_test/fn (util_test.clj:98)
    clojure.test$test_var$fn__10620.invoke (test.clj:716)
    clojure.test$test_var.invokeStatic (test.clj:716)
    clojure.test$test_var.invoke (test.clj:707)
    clojure.test$test_vars$fn__10646$fn__10651.invoke (test.clj:734)
    clojure.test$default_fixture.invokeStatic (test.clj:686)
    clojure.test$default_fixture.invoke (test.clj:682)
    clojure.test$test_vars$fn__10646.invoke (test.clj:734)
    clojure.test$default_fixture.invokeStatic (test.clj:686)
    clojure.test$default_fixture.invoke (test.clj:682)
    clojure.test$test_vars.invokeStatic (test.clj:730)
    clojure.test$test_all_vars.invokeStatic (test.clj:736)
    clojure.test$test_ns.invokeStatic (test.clj:757)
    clojure.test$test_ns.invoke (test.clj:742)
    clojure.core$map$fn__6881.invoke (core.clj:2728)
    clojure.lang.LazySeq.sval (LazySeq.java:40)
    clojure.lang.LazySeq.seq (LazySeq.java:49)
    clojure.lang.Cons.next (Cons.java:39)
    clojure.lang.RT.next (RT.java:703)
    clojure.core$next__6406.invokeStatic (core.clj:64)
    clojure.core$reduce1.invokeStatic (core.clj:936)
    clojure.core$reduce1.invokeStatic (core.clj:926)
    clojure.core$merge_with.invokeStatic (core.clj:3032)
    clojure.core$merge_with.doInvoke (core.clj:3024)
    clojure.lang.RestFn.applyTo (RestFn.java:139)
    clojure.core$apply.invokeStatic (core.clj:659)
    clojure.test$run_tests.invokeStatic (test.clj:767)
    clojure.test$run_tests.doInvoke (test.clj:767)
    clojure.lang.RestFn.applyTo (RestFn.java:137)
    clojure.core$apply.invokeStatic (core.clj:657)
    clojure.core$apply.invoke (core.clj:652)
    com.jakemccrary.test_refresh$run_selected_tests$fn__730.invoke (test_refresh.clj:153)
    com.jakemccrary.test_refresh$suppress_unselected_tests.invokeStatic (test_refresh.clj:115)
    com.jakemccrary.test_refresh$suppress_unselected_tests.invoke (test_refresh.clj:89)
    com.jakemccrary.test_refresh$run_selected_tests.invokeStatic (test_refresh.clj:151)
    com.jakemccrary.test_refresh$run_selected_tests.invoke (test_refresh.clj:142)
    com.jakemccrary.test_refresh$run_tests.invokeStatic (test_refresh.clj:166)
    com.jakemccrary.test_refresh$run_tests.invoke (test_refresh.clj:155)
    com.jakemccrary.test_refresh$monitor_project$fn__753.invoke (test_refresh.clj:257)
    com.jakemccrary.test_refresh$monitor_project.invokeStatic (test_refresh.clj:243)
    com.jakemccrary.test_refresh$monitor_project.invoke (test_refresh.clj:217)
    user$eval4029.invokeStatic (form-init5699477671972356714.clj:1)
    user$eval4029.invoke (form-init5699477671972356714.clj:1)
    clojure.lang.Compiler.eval (Compiler.java:6978)
    clojure.lang.Compiler.eval (Compiler.java:6968)
    clojure.lang.Compiler.load (Compiler.java:7430)
    clojure.lang.Compiler.loadFile (Compiler.java:7368)
    clojure.main$load_script.invokeStatic (main.clj:277)
    clojure.main$init_opt.invokeStatic (main.clj:279)
    clojure.main$init_opt.invoke (main.clj:279)
    clojure.main$initialize.invokeStatic (main.clj:310)
    clojure.main$null_opt.invokeStatic (main.clj:344)
    clojure.main$null_opt.invoke (main.clj:341)
    clojure.main$main.invokeStatic (main.clj:423)
    clojure.main$main.doInvoke (main.clj:386)
    clojure.lang.RestFn.applyTo (RestFn.java:137)
    clojure.lang.Var.applyTo (Var.java:700)
    clojure.main.main (main.java:37)

Enable calling `clojure.tools.namespace.repl/set-refresh-dirs` as part of setup.

.cljc files in /resources/ (such as those copied there during figwheel compilation) are picked up by default during clojure.tools.namespace.repl/refresh, which can stomp on code loaded into memory by test-refresh. By exposing clojure.tools.namespace.repl/set-refresh-dirs in some way as part of the test-refresh run, we can avoid this from happening.

For more detail, see a blog post I wrote detailing how I worked around the same issue with the Reloaded workflow

Compatibility with jaycfields/expectations

Hi,

Is there a specific reason that test-refresh doesn't work with https://github.com/jaycfields/expectations?

lein test works fine but lein test-refresh just doesn't seem to find any tests.

It's not a huge problem, I don't have to use it, but if it's a simple fix it would be great.

Thanks in advance.

Julian.

PS - I have a repo where you can see the problem if it helps: https://github.com/julianjelfs/agario3d

In here there are some tests inside game_test.clj and they are found by lein test but not by lein test-refresh.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.