Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display number of assertions in test results #184

Merged
merged 2 commits into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Next
* Displays the total number of assertions made in the test results

# 3.6.0
* Replaces `SpecFailure` and `SpecPending` classes with `ex-info`
* Replaces `mmargs` library with a Clojure implementation
Expand Down
2 changes: 1 addition & 1 deletion spec/clj/speclj/report/clojure_test_spec.clj
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

(describe "Clojure Test Reporter"
(with reporter (new-clojure-test-reporter))
(with a-failure (fail-result (new-characteristic "flips" (new-description "Crazy" false "some.ns") "flip" false) 0.3 (-new-failure "Expected flips")))
(with a-failure (fail-result (new-characteristic "flips" (new-description "Crazy" false "some.ns") "flip" false) 0.3 (-new-failure "Expected flips") 0))
(with an-error (error-result (-new-exception "Compilation failed")))

(it "reports pass"
Expand Down
12 changes: 6 additions & 6 deletions spec/cljc/speclj/report/documentation_spec.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@

(it "reports pass"
(let [characteristic (new-characteristic "says pass" @description "pass" false)
result (pass-result characteristic 1)]
result (pass-result characteristic 1 0)]
(should= (str (green "- says pass") endl)
(with-out-str (report-pass @reporter result)))))

(it "reports focused pass"
(let [characteristic (new-characteristic "says pass" @description #() true)
result (pass-result characteristic 1)]
result (pass-result characteristic 1 0)]
(should= (str (green "- says pass") " " (yellow "[FOCUS]") endl)
(with-out-str (report-pass @reporter result)))))

Expand All @@ -47,13 +47,13 @@

(it "reports fail"
(let [characteristic (new-characteristic "says fail" @description "fail" false)
result (fail-result characteristic 2 (-new-failure "blah"))]
result (fail-result characteristic 2 (-new-failure "blah") 0)]
(should= (str (red "- says fail (FAILED)") endl)
(with-out-str (report-fail @reporter result)))))

(it "reports focused fail"
(let [characteristic (new-characteristic "says fail" @description #() true)
result (fail-result characteristic 2 (-new-failure "blah"))]
result (fail-result characteristic 2 (-new-failure "blah") 0)]
(should= (str (red "- says fail (FAILED)") " " (yellow "[FOCUS]") endl)
(with-out-str (report-fail @reporter result)))))

Expand All @@ -71,13 +71,13 @@

(it "reports nested pass"
(let [characteristic (new-characteristic "nested pass" @nested-description "pass" false)
result (pass-result characteristic 1)]
result (pass-result characteristic 1 0)]
(should= (str (green " - nested pass") endl)
(with-out-str (report-pass @reporter result)))))

(it "reports nested failure"
(let [characteristic (new-characteristic "nested fail" @nested-description "fail" false)
result (fail-result characteristic 2 (-new-failure "blah"))]
result (fail-result characteristic 2 (-new-failure "blah") 0)]
(should= (str (red " - nested fail (FAILED)") endl)
(with-out-str (report-fail @reporter result)))))
)
Expand Down
28 changes: 14 additions & 14 deletions spec/cljc/speclj/report/progress_spec.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -55,27 +55,27 @@

(it "reports passing run results"
(binding [*color?* true]
(let [result1 (pass-result nil 0.1)
result2 (pass-result nil 0.02)
result3 (pass-result nil 0.003)
(let [result1 (pass-result nil 0.1 1)
result2 (pass-result nil 0.02 2)
result3 (pass-result nil 0.003 3)
results [result1 result2 result3]
output (with-out-str (report-runs @reporter results))
lines (str/split-lines output)]
(should= 4 (count lines))
(should= "" (nth lines 0))
(should= "" (nth lines 1))
(should= (str "Finished in " (platform/format-seconds 0.123) " seconds") (nth lines 2))
(should= (green "3 examples, 0 failures") (nth lines 3)))))
(should= (green "3 examples, 0 failures, 6 assertions") (nth lines 3)))))

(it "reports failing run results"
(binding [*color?* true]
(let [description (new-description "Crazy" false "some.ns")
char1 (new-characteristic "flips" description "flip" false)
char2 (new-characteristic "spins" description "spin" false)
char3 (new-characteristic "dives" description "dive" false)
result1 (fail-result char1 0.3 (-new-failure "Expected flips"))
result2 (fail-result char2 0.02 (-new-failure "Expected spins"))
result3 (fail-result char3 0.001 (-new-failure "Expected dives"))
result1 (fail-result char1 0.3 (-new-failure "Expected flips") 1)
result2 (fail-result char2 0.02 (-new-failure "Expected spins") 2)
result3 (fail-result char3 0.001 (-new-failure "Expected dives") 3)
results [result1 result2 result3]
lines (str/split-lines (with-out-str (report-runs @reporter results)))]
(should= 18 (count lines))
Expand All @@ -95,18 +95,18 @@
; (should= "/Users/micahmartin/Projects/clojure/speclj/spec/speclj/report/progress_spec.clj:56" (nth lines 14))
(should= "" (nth lines 15))
(should= (str "Finished in " (platform/format-seconds 0.321) " seconds") (nth lines 16))
(should= (red "3 examples, 3 failures") (nth lines 17)))))
(should= (red "3 examples, 3 failures, 6 assertions") (nth lines 17)))))

(it "reports pending run results"
(binding [*color?* true]
(let [description (new-description "Crazy" false "some.ns")
char1 (new-characteristic "flips" description "flip" false)
result1 (pass-result char1 0.1)
result2 (pass-result char1 0.02)
result1 (pass-result char1 0.1 1)
result2 (pass-result char1 0.02 2)
result3 (pending-result char1 0.003 (-new-pending "Blah"))
results [result1 result2 result3]
lines (str/split-lines (with-out-str (sut/print-summary results)))]
(should= (yellow "3 examples, 0 failures, 1 pending") (last lines)))))
(should= (yellow "3 examples, 0 failures, 3 assertions, 1 pending") (last lines)))))

(it "reports pending summary"
(let [description (new-description "Crazy" false "some.ns")
Expand Down Expand Up @@ -134,12 +134,12 @@
(binding [*color?* true]
(let [description (new-description "Crazy" false "some.ns")
char1 (new-characteristic "flips" description "flip" false)
result1 (pass-result char1 0.1)
result2 (pass-result char1 0.02)
result1 (pass-result char1 0.1 3)
result2 (pass-result char1 0.02 2)
result3 (error-result (-new-exception "blah"))
results [result1 result2 result3]
lines (str/split-lines (with-out-str (sut/print-summary results)))]
(should= (red "3 examples, 0 failures, 1 errors") (last lines)))))
(should= (red "3 examples, 0 failures, 5 assertions, 1 errors") (last lines)))))

(it "reports error summary"
(binding [*full-stack-trace?* false]
Expand Down
Loading