Thanks Brenton and Stuart, that was very insightful.

Shantanu

On Feb 26, 11:58 pm, Brenton <bashw...@gmail.com> wrote:
> Shantanu,
>
> I have been experimenting with this in ClojureScript One. The latest
> version is in the M003 branch.
>
> The example that Stuart links to is a complex integration test. Here
> is an example of some unit tests which test ClojureScript code.
>
> https://github.com/brentonashworth/one/blob/M003/test/one/test/dispat...
>
> The idea is to keep writing tests in Clojure using clojure.test but
> add the ability to easily evaluate some forms in a JavaScript
> environment. This allows you to have one test suite for a Clojure/
> ClojureScript project with integrated test results. The same technique
> could be used with other test frameworks.
>
> In the above example, you set up the test namespace in the same way
> you would with Clojure tests.
>
> You then have the `in-javascript` macro which sets up the
> ClojureScript namespace and allows you to define functions that you
> can call from ClojureScript in the tests below. All ClojureScript in
> the tests below will be evaluated in the namespace that you set up
> here.
>
> In your tests, when you want to evaluate something in the JavaScript
> environment, you wrap that form in the `js` macro.
>
> If you checkout this branch you can run tests in three ways:
>
> 1) `lein test` will run all the tests as it normally would. The
> current setup will launch a browser which can be used as the
> evaluation environment.
>
> 2) You can run tests from a Clojure REPL:
>
> (dev-server)
> (require 'one.test)
> (require 'clojure.test)
> (require 'one.test.dispatch)
>
> (def ee (one.test/browser-eval-env))
>
> ;; go to the development or fresh page
>
> (binding [one.test/*eval-env* ee]
>   (clojure.test/run-tests 'one.test.dispatch))
>
> 3) If you are in a ClojureScript REPL, you can run the tests with:
>
> (run-tests 'one.test.dispatch)
>
> In each case you need to have a JavaScript environment in which to
> evaluation things. In case 1 this is created for you. In case 2 you
> have to manually set it up. In case 3 it uses the active ClojureScript
> REPL's environment.
>
> This is all very experimental. I hope it gives you some good ideas for
> where to start.
>
> Thanks,
> Brenton
>
> On Feb 25, 11:34 pm, Shantanu Kumar <kumar.shant...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Hi,
>
> > Has anybody got clojure.test working with ClojureScript? Is it planned
> > for clojure.test to eventually work on ClojureScript?
>
> > Shantanu

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to