Skip to content

Enable REPL-based testing. - #24

Open
sinistral wants to merge 1 commit into
adzerk-oss:masterfrom
sinistral:develop.repl-test
Open

Enable REPL-based testing.#24
sinistral wants to merge 1 commit into
adzerk-oss:masterfrom
sinistral:develop.repl-test

Conversation

@sinistral

@sinistral sinistral commented May 9, 2016

Copy link
Copy Markdown
Contributor

screen shot 2016-05-06 at 21 04 20
Test sources are not currently part of the ClojureScript build.
Although the test namespaces themselves may be dispatched to the
REPL (e.g. C-k in CIDER), the libraries upon which they depend won't
have been compiled and won't be available.

The example testing task has been extended to inject testing
namespaces for each namespace that is required by the build (EDN)
configuration. It assumes that the convention of naming test namespaces
by appending -test to the source namespace is honoured. This isn't
too restrictive since this is already required for boot-cljs-test to
run tests. Injecting the test namespaces spares users from having to duplicate
build configuration only to add testing namespaces, and then keep the
two synchronised.

In a REPL, tests now run as:

cljs.user> (app.core-test/silly-test)

FAIL in (silly-test) (cljs$test$run_block@http:365:17)
expected: (= (+ 1 1) 3)
  actual: (not (= 2 3))
;; => nil

rather than:

cljs.user> (app.core-test/silly-test)

eval code
eval@[native code]
http://localhost:3000/main.out/weasel/repl.js:30:469
http://localhost:3000/main.out/weasel/repl.js:39:4
G__10698__2@http://localhost:3000/main.out/cljs/core.js:31903:110
G__10698@http://localhost:3000/main.out/cljs/core.js:32170:24
http://localhost:3000/main.out/weasel/repl.js:184:75
fireListeners@http://localhost:3000/main.out/goog/events/eventtarget.js:284:27
dispatchEventInternal_@http://localhost:3000/main.out/goog/events/eventtarget.js:381:39
dispatchEvent@http://localhost:3000/main.out/goog/events/eventtarget.js:196:56
onMessage_@http://localhost:3000/main.out/goog/net/websocket.js:426:21
[native code]

Test sources are not currently part of the ClojureScript build.
Although the test namespaces themselves may be dispatched to the
REPL (e.g. C-k in CIDER), the libraries upon which they depend won't
have been compiled and won't be available.

The example `testing` task has been extended to inject testing
namespaces for each namespace that is required by the build (EDN)
configuration.  It assumes that the convention of naming test namespaces
by appending `-test` to the source namespace is honoured.  This isn't
too restrictive since this is already required for `boot-cljs-test` to
run tests.  Injecting the test namespaces spares users from having to duplicate
build configuration only to add testing namespaces, and then keep the
two synchronised.

In a REPL, tests now run as:
```
cljs.user> (app.core-test/silly-test)

FAIL in (silly-test) (cljs$test$run_block@http:365:17)
expected: (= (+ 1 1) 3)
  actual: (not (= 2 3))
;; => nil
```
rather than:
```
cljs.user> (app.core-test/silly-test)

eval code
eval@[native code]
http://localhost:3000/main.out/weasel/repl.js:30:469
http://localhost:3000/main.out/weasel/repl.js:39:4
G__10698__2@http://localhost:3000/main.out/cljs/core.js:31903:110
G__10698@http://localhost:3000/main.out/cljs/core.js:32170:24
http://localhost:3000/main.out/weasel/repl.js:184:75
fireListeners@http://localhost:3000/main.out/goog/events/eventtarget.js:284:27
dispatchEventInternal_@http://localhost:3000/main.out/goog/events/eventtarget.js:381:39
dispatchEvent@http://localhost:3000/main.out/goog/events/eventtarget.js:196:56
onMessage_@http://localhost:3000/main.out/goog/net/websocket.js:426:21
[native code]
```
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

Successfully merging this pull request may close these issues.

1 participant