This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-06-13
Channels
- # admin-announcements (1)
- # beginners (10)
- # boot (15)
- # cider (9)
- # clara (195)
- # cljsrn (24)
- # clojars (20)
- # clojure (46)
- # clojure-android (1)
- # clojure-germany (15)
- # clojure-greece (16)
- # clojure-nl (1)
- # clojure-russia (13)
- # clojure-spec (28)
- # clojure-uk (44)
- # clojurescript (104)
- # clojurex (1)
- # component (7)
- # css (2)
- # cursive (27)
- # datomic (92)
- # dirac (12)
- # emacs (5)
- # lambdaisland (3)
- # lein-figwheel (36)
- # mount (87)
- # off-topic (8)
- # om (102)
- # om-next (3)
- # onyx (30)
- # pedestal (3)
- # re-frame (26)
- # reagent (20)
- # robots (4)
- # specter (18)
- # spirituality-ethics (1)
- # untangled (127)
- # yada (11)
is there any good example how to use mount (or mount-lite too, i guess) with some test framework? im actually trying to figure out how intellij's repl based testing is supposed to work and how to make it a smooth experience with mount-lite.
@onetom: are you looking for something specific? Usually these are used when testing: https://github.com/tolitius/mount#composing-states mostly swap
and only
. The idea is you would start a portion of an app that you want to test, and swap the real external resources with a mocked ones (whether it is a function or another state..)
im looking for an example of how is it done.
via some fixtures, or macros like with-components
in https://github.com/stuartsierra/component/issues/6?
what would i do with a datomic db for example?
create a new one in every test namesapce and transact the schema into it?
how does it play together with intellij's "Run test under caret in REPL" & "Run tests in current NS in REPL" features?
or there is eftest
(https://github.com/weavejester/eftest) which is also used by https://github.com/metosin/boot-alt-test
which allows parallel test runs.
is there a way to use them with mount/mount-lite, since they only allow one active state at a time?
for example i saw this: https://github.com/tolitius/mount/blob/master/README.md#swapping-alternate-implementations
what happens if there is an exception in the ;; testing.. checking "sms-ch" channel
part?
the (mount/stop)
bit wouldn't run, then, no?
if i start a REPL, then i would have a real system running in it by default.
but if im running tests with intellij via REPL and those tests would have (mount/start-with {...some-mocks...})
, then how am i supposed to get back my real system afterwards?
> how am i supposed to get back my real system afterwards? what do you mean get back to the real system?
i have this at the moment:
(deftask dev
"Backend in development mode"
[]
(comp
(repl :server true)
(watch)
(system.boot/system
:sys #'sys/dev
:auto true
:files ["sys.clj" "core.clj"])))
I usually run tests in the separate REPL: i.e. boot watch speak test
. I like it better, since things / components / app pieces are decoupled from compilation differences / configs
which does have a quite nice clojure.test
integration and it's super fast to just run specific tests and it automatically reloads the necessary changed files too
I never liked running tests and dev within the same REPL. at the times I used leinigen
it was a no brainer, since it just works the best in two separate REPLs, "lein does not clean well" especially if new things are added in project.clj
.
with boot clean
is no longer the problem, but boot watch speak test
is just really niice, since it just works for you in a different REPL with no dev cluttering.
I only use IntelliJ for Java and Scala (I use VIM for Clojure), so I would appreciate if someone with Cursive knowledge jump in, but.. "you can't start two REPLs with Cursive"?
i was also trying to run boot watch test
in a terminal within intellij, but if i close the project window, boot
keeps running in the background and i can't access it anymore (have to kill
it manually)
and let's not forget that most people are not RAM millionaires either. running 2 repls is not nice at all...
I just did start two REPLs in Cursive, and when I did "File => Close Project" it asked me twice whether I wanted to stop the REPL, you don't have the same behavior?
> not sure how would i tell intellij which repls should it send the tests to you don't, it is in your boot test src
we already have a datomic transactor, a frontend project with cljs compiler & cljs-repl aaaand a backend process
> a datomic transactor, a frontend project with cljs compiler & cljs-repl aaaand a backend process is this the same project?
closing the repls is not the problem. closing the terminals which run boot watch test
are the problem
no. these are 3 JVMs. i was just mentioning it, regarding you advice to run an extra one just for the tests
and no, frontend and backend are 2 different boot processes already (in separate source repos too)
so i have 2 intellij projects open 1. frontend (hoplon) 2. backend (ring app via boot-jetty)
and it sends the tests to the boot dev
process via the nREPL client but 1st reloads the modified files also via the REPL
as documented here: https://cursive-ide.com/userguide/testing.html
(im working on a green field project, that's why im trying to revise my workflow and get away from component
and try use mount
or mount-lite
instead)
I see, but then why not just run tests continuously vs. say cmd-shift-a "run tests in current NS in REPL"
?
because clojure.test
doesn't support
1. re-running only the last failing tests
2. running only specific tests (so i can get immediate feedback)
3. how would i run the separate REPL? start another boot
nREPL server process? and open an nREPL client to it which I would setup as a second Run configuration
in IntelliJ on some hardwired port?
it would be great if it could send stuff into a test pod of course, but unfortunately i have no idea what cursive is really doing in the background...
maybe we should interrogate mr fleming on that end but im not sure it worth harassing him, since this issue doesn't seem to move forward: https://github.com/cursive-ide/cursive/issues/692
he might be able to explain if it's possible to make a REPL connection for test evaluation
maybe we should ask him how does he manages state, so this feature is useful for him...
looking into yurt in the mean time. i remember i read about it before but probably just before sleep... http://www.dotkam.com/2016/01/31/yurt-mounts-local-real-estate/ > 504 Gateway Time-out
@tolitius:
you said:
> with boot clean
is no longer the problem, but boot watch speak test
is just really niice, since it just works for you in a different REPL with no dev cluttering.
and in the yurt-mounts-local-real-estate article:
> The way I do it today is simply running:
>
boot watch speak test
> in a different REPL.
but how boot watch speak test
is a REPL?
you mean different JVM process?as i was going thru the mount
tests and also you example apps and i see this pattern everywhere:
https://github.com/tolitius/stater/blob/master/smsio/test/app/test/app.clj#L14-L21
there is no exception handling for proper cleanup, like this:
(try
(mount/start)
...
(is ...)
(finally
(mount/stop))
without such wrapping one mistake can force you to restart the test process, because there will be a web-server started which would cause subsequent tests to fail with "Address already in use" errors, even after you fix the mistake.just provide an extra parameter to http/post
on L19 and you will see the next test (`swapping-with-state`) will fail too
removing the extra param should make the tests pass again, but instead of 1 error, you will get 2 and wading through the reams of log messages, you can discover the "Address already in use" error
there is this in mount-lite
which seems to mitigate the problem without the try-finally
block but im not sure it's enough either:
https://github.com/aroemers/mount-lite/blob/master/test/mount/lite_test.clj#L21