duplication of tests

95 views
Skip to first unread message

Maaruks

unread,
Aug 14, 2012, 10:32:00 AM8/14/12
to spe...@googlegroups.com
Every time I do run-specs in REPL number of tests increases by one:
It seems that describe macro adds tests to a collection that doesn't get reset.

user> (use 'speclj.core)
nil
user> (run-specs)
.

Finished in 0.00020 seconds
1 examples, 0 failures
nil
user> (run-specs)
.

Finished in 0.00021 seconds
2 examples, 0 failures
nil
user> (run-specs)
.

Finished in 0.00022 seconds
3 examples, 0 failures
nil

My test:

(defn true-or-false []
  true)

(describe "truthiness"
  (it "tests if true-or-false? returns true"
      (should (true-or-false))))

Maaruks

unread,
Aug 16, 2012, 12:28:03 PM8/16/12
to spe...@googlegroups.com
hello ?      Is no one using speclj from REPL ?   

There must be some var that stores tests.   It could be reset from repl.   Need to look at speclj source code....

Micah Martin

unread,
Aug 16, 2012, 12:30:59 PM8/16/12
to spe...@googlegroups.com
Maarkus,

Running from the REPL is not something I typically do. The auto-runner (lein spec -a) gives me faster feedback. However, speclj should still be able to run fine in the REPL. So I consider this a bug.

Micah

Maaruks

unread,
Aug 16, 2012, 12:50:08 PM8/16/12
to spe...@googlegroups.com

I hope someone will fix it.
I am using speclj at work and we use maven.   CI server doesn't know how to run lein.    So no auto-runner for me. 

Speclj works from maven but not with -a  option.     spec  source directory isn't on classpath.

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.2.1</version>
                <executions>
                    <execution>
                        <phase>test</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <executable>java</executable>
   <classpathScope>test</classpathScope>
                    <arguments>
                        <argument>-classpath</argument>
                        <classpath/>
                        <argument>speclj.main</argument>
                        <!--argument>-a</argument-->
                    </arguments>
                </configuration>
            </plugin>

Micah Martin

unread,
Aug 20, 2012, 3:21:38 PM8/20/12
to spe...@googlegroups.com
Maarkus,

Speclj 2.3.0 was released today with a fix that should solve your problem.  The results are cleared after each run.  So multiple runs should print the correct report.

Micah

Maaruks

unread,
Aug 24, 2012, 12:41:21 PM8/24/12
to spe...@googlegroups.com

thank you

It works better now.   Results do get cleared after each run.

But it seems that tests accumulate when I recompile code in emacs.   

Lets say,   if I have two tests  then  every time I compile my tests  it will add two tests to speclj. 

So....  when I do (run-specs)   it will run 10 tests although I have only two.


Maris

Micah Martin

unread,
Aug 27, 2012, 2:23:36 PM8/27/12
to spe...@googlegroups.com
I'm not familiar with how emacs integrates with Clojure.

When you say you recompile the code, does that mean you're compiling the clojure source into .class files?

Micah

Maaruks

unread,
Aug 28, 2012, 7:40:05 AM8/28/12
to spe...@googlegroups.com

In emacs  C-c C-k invokes slime function slime-compile-and-load-file.

It makes clojure to evaluate current buffer.   So it evaluates all test definitions as well.

I guess describe macro adds tests to a collection every time it gets called. 


(deftype Description [name ns parent children charcteristics tags befores before-alls afters after-alls withs with-alls arounds]
  SpecComponent
  (install [this description]
    (reset! (.parent this) description)
    (swap! (.children description) conj this))
  Object
  (toString [this] (str "Description: " \" name \")))

Micah Martin

unread,
Aug 28, 2012, 12:28:53 PM8/28/12
to spe...@googlegroups.com
Ahhh.  I see.  You're right.

Speclj 2.3.1 (just released) should solve the problem.

Micah

Maaruks

unread,
Sep 3, 2012, 5:19:53 PM9/3/12
to spe...@googlegroups.com

yes, problem solved
thanks
Reply all
Reply to author
Forward
0 new messages