Skip to content

Commit

Permalink
Merge tag '0.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
pjstadig committed Mar 12, 2013
2 parents 8c7d08a + 11cd2d1 commit c69604a
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .dir-locals.el
Expand Up @@ -3,4 +3,4 @@
(eval ignore-errors
(require 'whitespace)
(whitespace-mode t))))
(clojure-mode . ((clojure-test-ns-segment-position . 2))))
(clojure-mode . ((clojure-test-ns-segment-position . 1))))
4 changes: 4 additions & 0 deletions CHANGELOG.org
@@ -1,5 +1,9 @@
#+STARTUP: hidestars showall
* conjecture changelog
** 0.3.0
- Compatible with Clojure 1.2.1.
- Renamed groupId to conjecture.
- Renamed namespaces from name.stadig.* => conjecture
** 0.2.0
- Runs fixtures when you call a function as a test (e.g. at a REPL)
- Removes support for singleton fixtures. They did not provide an
Expand Down
8 changes: 4 additions & 4 deletions README.org
Expand Up @@ -3,23 +3,23 @@
A ~clojure.test~ compatible third-party testing library for Clojure. Please
contribute code and features through GitHub issues and pull requests.
** Usage
Same as ~clojure.test~, except you pull in ~name.stadig.conjecture~.
Same as ~clojure.test~, except you pull in ~conjecture.core~.

For example, you would add the following dependency to your project.clj:

: :dependencies [[name.stadig/conjecture "0.2.0"]]

Use ~name.stadig.conjecture~ in your tests:
Use ~conjecture.core~ in your tests:

: (ns foo.bar.test
: (:use [name.stadig.conjecture]))
: (:use [conjecture.core]))
:
: (deftest test-widget
: (is (= foo bar))
: ...)

Conjecture is compatible with any ~clojure.test~ based tests you may have.
You simply swap ~name.stadig.conjecture~ in for ~clojure.test~.
You simply swap ~conjecture.core~ in for ~clojure.test~.

You can add the lein-conjecture plugin to your project.clj, if that's your
style:
Expand Down
6 changes: 3 additions & 3 deletions project.clj
@@ -1,9 +1,9 @@
(defproject name.stadig/conjecture "0.2.0"
(defproject conjecture "0.3.0"
:description "A clojure.test compatible third-party testing library for
Clojure."
:url "http://github.com/pjstadig/conjecture"
:license {:name "Eclipse Public License - v 1.0"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.5.0"]]
:plugins [[name.stadig/lein-conjecture "0.1.0"]]
:dependencies [[org.clojure/clojure "1.2.1"]]
:plugins [[lein-conjecture "0.2.0"]]
:aliases {"test" "conjecture"})
20 changes: 10 additions & 10 deletions src/name/stadig/conjecture.clj → src/conjecture/core.clj
Expand Up @@ -234,7 +234,7 @@
For additional event types, see the examples in the code.
"}
name.stadig.conjecture
conjecture.core
(:require [clojure.template :as temp]
[clojure.stacktrace :as stack]))

Expand All @@ -244,14 +244,14 @@

;;; USER-MODIFIABLE GLOBALS

(defonce ^:dynamic
(defonce ^{:dynamic true}
^{:doc "True by default. If set to false, no test functions will
be created by deftest, set-test, or with-test. Use this to omit
tests when compiling or loading production code."
:added "0.1.0"}
*load-tests* true)

(def ^:dynamic
(def ^{:dynamic true}
^{:doc "The maximum depth of stack traces to print when an Exception
is thrown during a test. Defaults to nil, which means print the
complete stack trace."
Expand All @@ -262,20 +262,20 @@
;;; GLOBALS USED BY THE REPORTING FUNCTIONS

;; bound to a ref of a map in test-ns
(def ^:dynamic *report-counters* nil)
(def ^{:dynamic true} *report-counters* nil)

;; used to initialize *report-counters*
(def ^:dynamic *initial-report-counters*
(def ^{:dynamic true} *initial-report-counters*
{:test 0, :pass 0, :fail 0, :error 0})

;; bound to hierarchy of vars being tested
(def ^:dynamic *testing-vars* (list))
(def ^{:dynamic true} *testing-vars* (list))

;; bound to hierarchy of "testing" strings
(def ^:dynamic *testing-contexts* (list))
(def ^{:dynamic true} *testing-contexts* (list))

;; ; bound to hierarchy of "testing" strings
(def ^:dynamic *test-out* *out*)
(def ^{:dynamic true} *test-out* *out*)

(defmacro with-test-out
"Runs body with *out* bound to the value of *test-out*."
Expand Down Expand Up @@ -711,9 +711,9 @@
(defn each-fixture-fn [ns]
(join-fixtures (::each-fixtures (meta ns))))

(def ^:dynamic *once-fixtures* #{})
(def ^{:dynamic true} *once-fixtures* #{})

(def ^:dynamic *each-fixtures* #{})
(def ^{:dynamic true} *each-fixtures* #{})

(defn test-var
"If v has a function in its :test metadata, calls that function,
Expand Down
19 changes: 9 additions & 10 deletions src/name/stadig/conjecture/junit.clj → src/conjecture/junit.clj
Expand Up @@ -9,7 +9,7 @@
;;;;
;;;; You must not remove this notice, or any other, from this software.

;; test/junit.clj: Extension to name.stadig.conjecture for JUnit-compatible
;; test/junit.clj: Extension to conjecture.core for JUnit-compatible
;; XML output

;; by Jason Sankey
Expand All @@ -18,29 +18,28 @@
;; DOCUMENTATION
;;

(ns ^{:doc "name.stadig.conjecture extension for JUnit-compatible XML output.
(ns ^{:doc "conjecture.core extension for JUnit-compatible XML output.
JUnit (http://junit.org/) is the most popular unit-testing library
for Java. As such, tool support for JUnit output formats is
common. By producing compatible output from tests, this tool
support can be exploited.
To use, wrap any calls to name.stadig.conjecture/run-tests in the
To use, wrap any calls to conjecture.core/run-tests in the
with-junit-output macro, like this:
(use 'name.stadig.conjecture)
(use 'name.stadig.conjecture.junit)
(use 'conjecture.core)
(use 'conjecture.junit)
(with-junit-output
(run-tests 'my.cool.library))
To write the output to a file, rebind name.stadig.conjecture/*test-out* to
your own PrintWriter (perhaps opened using
clojure.java.io/writer)."
To write the output to a file, rebind conjecture.core/*test-out* to
your own PrintWriter (perhaps opened using clojure.java.io/writer)."
:author "Jason Sankey"}
name.stadig.conjecture.junit
conjecture.junit
(:require [clojure.stacktrace :as stack]
[name.stadig.conjecture :as t]))
[conjecture.core :as t]))

;; copied from clojure.contrib.lazy-xml
(def ^{:private true}
Expand Down
15 changes: 7 additions & 8 deletions src/name/stadig/conjecture/tap.clj → src/conjecture/tap.clj
Expand Up @@ -9,7 +9,7 @@
;;;;
;;;; You must not remove this notice, or any other, from this software.

;;; test_is/tap.clj: Extension to name.stadig.conjecture for TAP output
;;; test_is/tap.clj: Extension to conjecture.core for TAP output

;; by Stuart Sierra
;; March 31, 2009
Expand All @@ -20,7 +20,7 @@
;; DOCUMENTATION
;;

(ns ^{:doc "name.stadig.conjecture extensions for the Test Anything Protocol
(ns ^{:doc "conjecture.core extensions for the Test Anything Protocol
(TAP)
TAP is a simple text-based syntax for reporting test results. TAP
Expand All @@ -30,17 +30,16 @@
http://search.cpan.org/~petdance/TAP-1.0.0/TAP.pm
To use this library, wrap any calls to
name.stadig.conjecture/run-tests in the with-tap-output macro,
like this:
conjecture.core/run-tests in the with-tap-output macro, like this:
(use 'name.stadig.conjecture)
(use 'name.stadig.conjecture.tap)
(use 'conjecture.core)
(use 'conjecture.tap)
(with-tap-output
(run-tests 'my.cool.library))"
:author "Stuart Sierra"}
name.stadig.conjecture.tap
(:require [name.stadig.conjecture :as t]
conjecture.tap
(:require [conjecture.core :as t]
[clojure.stacktrace :as stack]))

(defn print-tap-plan
Expand Down
Expand Up @@ -17,8 +17,8 @@
;; Thanks to Chas Emerick, Allen Rohner, and Stuart Halloway for
;; contributions and suggestions.

(ns name.stadig.test.conjecture
(:use name.stadig.conjecture))
(ns conjecture.test.core
(:use conjecture.core))

(deftest can-test-symbol
(let [x true]
Expand All @@ -34,17 +34,17 @@
(is nil "Should fail"))

(deftest can-test-=
(is (= 2 (+ 1 1)) "Should pass")
(is (= 3 (+ 2 2)) "Should fail"))
(is (= "foobar" (str "foo" "bar")) "Should pass")
(is (= "notfoobar" (str "foo" "bar")) "Should fail"))

(deftest can-test-instance
(is (instance? Long (+ 2 2)) "Should pass")
(is (instance? Float (+ 1 1)) "Should fail"))
(is (instance? String (str "foo" "bar")) "Should pass")
(is (instance? Float (str "foo" "bar")) "Should fail"))

(deftest can-test-thrown
(is (thrown? ArithmeticException (/ 1 0)) "Should pass")
;; No exception is thrown:
(is (thrown? Exception (+ 1 1)) "Should fail")
(is (thrown? Exception (str "foo" "bar")) "Should fail")
;; Wrong class of exception is thrown:
(is (thrown? ArithmeticException (throw (RuntimeException.))) "Should error"))

Expand All @@ -55,7 +55,8 @@
(is (thrown-with-msg? ArithmeticException #"Something else" (/ 1 0))
"Should fail")
;; No exception is thrown:
(is (thrown? Exception (+ 1 1)) "Should fail")
(is (thrown-with-msg? Exception #"Not an Exception"
(str "foo" "bar")) "Should fail")
;; Wrong class of exception is thrown:
(is (thrown-with-msg? IllegalArgumentException #"Divide by zero" (/ 1 0))
"Should error"))
Expand Down Expand Up @@ -117,7 +118,7 @@
(defn test-ns-hook []
(binding [original-report report
report custom-report]
(test-all-vars (find-ns 'name.stadig.test.conjecture))))
(test-all-vars (find-ns 'conjecture.test.core))))

(deftest test-idempotent-fixture
(let [count (atom 0)
Expand Down
Expand Up @@ -14,12 +14,15 @@
;; by Stuart Sierra
;; March 28, 2009

(ns name.stadig.test.conjecture.fixtures
(:use name.stadig.conjecture))
(ns conjecture.test.fixtures
(:use conjecture.core))

(declare ^:dynamic *a* ^:dynamic *b* ^:dynamic *c* ^:dynamic *d*)
(declare ^{:dynamic true} *a*
^{:dynamic true} *b*
^{:dynamic true} *c*
^{:dynamic true} *d*)

(def ^:dynamic *n* 0)
(def ^{:dynamic true} *n* 0)

(defn fixture-a [f]
(binding [*a* 3] (f)))
Expand Down

0 comments on commit c69604a

Please sign in to comment.