So, here's an example:
In the file C:\Projects\CDT\Newton\src\Newton.utilities.clj I have:
(ns Newton.utilities)
;; To keep same name conventions as utilities.lisp
;; In idomatic clojure, this could be replaced by the anonymous function
;; #(apply + %)
(defn sum
"sums the elements of a list"
[list]
(apply + list))
As a first stab, I edited the file
C:\Projects\CDT\Newton\test\Newton\test\core.clj to:
(ns Newton.test.core
(:use [Newton.core])
(:use [clojure.test]))
;;(deftest replace-me ;; FIXME: write
;; (is false "No tests have been written."))
(deftest sum-test
(is (= (#'Newton.utilities/sum '(1 2 3 4 5)) 15)))
Then lein test gives me:
PS C:\Projects\CDT\Newton> lein test
Exception in thread "main" java.lang.RuntimeException: Unable to resolve
var: Ne
wton.utilities/sum in this context, compiling:(Newton/test/core.clj:9)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6416)
at clojure.lang.Compiler.analyze(Compiler.java:6216)
at clojure.lang.Compiler.analyze(Compiler.java:6177)
at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3452)
...
What am I doing wrong?
Thanks,
Adam
On Wed, Nov 30, 2011 at 10:30 PM, Adam Getchell <[email protected]>wrote:
> Hello,
>
> I'm porting a scientific application written in SBCL to Clojure. I'd like
> to do the right thing by setting up tests to ensure my functions are
> correct, and package up the project correctly using Leiningen.
>
> I've read "Clojure in Action", however, the sample code from Chapter 8,
> which details TDD, didn't work in my environment (I'm using IntelliJ +
> LaClojure).
>
> I've also read over the Leiningen tutorial here:
> https://github.com/technomancy/leiningen/blob/master/doc/TUTORIAL.md which
> makes a passing reference to using "lein test".
>
> However, I haven't put together how I should setup a proper test suite to
> generate tests for functions I have defined in, say, a file called
> "utilities.clj".
>
> Any pointers/hints? For example, what do I name a file such that my
> "deftests" get invoked by Leiningen correctly?
>
> Thanks,
>
> Adam Getchell
> --
> "Invincibility is in oneself, vulnerability in the opponent." -- Sun Tzu
>
--
"Invincibility is in oneself, vulnerability in the opponent." -- Sun Tzu
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en