Questions tagged [clojure.test]

Unit test framework for clojure.

Clojure.test API is a unit test framework.

23 questions
37
votes
1 answer

Clojure.test and Leinigen: How to run just a single test from command line

this: Run one Clojure test (not all tests in a namespace), with fixtures, from the REPL works fine with repl, how can I do this from command line using Leinigen?
Tomas Kulich
  • 14,388
  • 4
  • 30
  • 35
4
votes
1 answer

lein test with-profile unable to override test profile's env value

I am doing some Clojure pet project. I have some profiles like the following {:test {:env {:database-name "library_test", :host-name "192.168.33.10" :username "library_admin" …
3
votes
2 answers

How to disable test fixtures when no tests are running in the current namespace?

I have seen many clojure projects that disable integration tests by default by adding this setting to project.clj: :test-selectors {:default (complement :integration) :integration :integration} But, if a namespace contains only…
Philip
  • 4,128
  • 5
  • 31
  • 49
3
votes
2 answers

How do I measure time taken per namepace to run clojure tests?

Is there a way to instrument the code and find out how much time each namespace takes or the only way forward is to use fixtures? What is a good approach for solving such a problem?
Amogh Talpallikar
  • 12,084
  • 13
  • 79
  • 135
2
votes
1 answer

Clojure Test with Multiple Assertions and Reporting

I'm running into some issues with reporting on failures using the clojure.test testing framework. Now, I understand that I can override some functions for different reporting so that it prints out to the console or wherever I want it to print to. I…
rAFTA
  • 35
  • 5
2
votes
1 answer

with-redefs does not work in specific project on Windows

I am having a hard time creating a simple unit test in Clojure using with-redefs for mocking on Windows. The test code, the function I'm about to test and the function to be mocked are all in different namespaces/files: Function under test: (ns…
skarfiol
  • 131
  • 10
2
votes
1 answer

clojure test that assertion throws

I have a function defined as: (defn strict-get [m key] {:pre [(is (contains? m key))]} (get m key)) And then I have a test for it: (is (thrown? java.lang.AssertionError (strict-get {} :abc))) However this test fails: ;; FAIL in ()…
nha
  • 17,623
  • 13
  • 87
  • 133
2
votes
2 answers

A way to chain the test, one running after the other in clojure?

Lein test runs my functions in random order. I have two functions that modify the same data. I need the first one running first and the second one after that. The order in my test firles Example: ;;===============my file============= ;;this fails…
Coding Enthusiast
  • 3,865
  • 1
  • 27
  • 50
1
vote
1 answer

Is there a verbose/colored mode for `lein test` / `clojure.test`?

The default output from clojure.test via lein test is pretty underwhelming: Ran 1 tests containing 1 assertions. 0 failures, 0 errors. I guess maybe Clojure people are minimalists, but in every other language I've used test runners use red/green…
Sasgorilla
  • 2,403
  • 2
  • 29
  • 56
1
vote
1 answer

Why can't with-redefs be applied around a deftest?

The with-redefs function appears to be just what is needed to mock/stub out dependencies in clojure tests. I'm using clojure.test [1.10.1] Initially it gave me a lot of grief, where the new bindings were not applied when I ran the test. Finally I…
Gishu
  • 134,492
  • 47
  • 225
  • 308
1
vote
1 answer

Why does my AWS CodeBuild test report result in an 'Incomplete' status?

I am trying to understand why my JUnit XML report results in an Incomplete status on AWS CodeBuild. The XML is produced by Kaocha, a Clojure test runner, through its kaocha-junit-xml plugin. At the end of my test run, the XML is generated and then…
johanmynhardt
  • 271
  • 3
  • 7
1
vote
1 answer

Is there a way in lein to run clojure tests from a jar file?

I would like to build a jar file containing a suite of clojure.test tests, and then use lein test to run those tests. As far as I can tell, :test-paths only supports paths to test source, not test jars. Is there a way to accomplish this?
dposada
  • 889
  • 1
  • 7
  • 15
1
vote
1 answer

Why is my `with-redefs-fn` rebinding ignored?

I am attempting to replace the stacktrace-file-and-line (private) function in clojure.test, but using with-redefs-fn when running tests seems to have no effect. When I execute the following code the original stacktrace-file-and-line is called…
James
  • 475
  • 4
  • 12
1
vote
1 answer

Spacemacs Cider test does not fail

When I run a test in Spacemacs with Clojure mode via m t t it does not show a failure, even when the test clearly fails. See: 1 is not equal to 2, but still there are 0 test failures. How can I make the test fail?
user2609980
  • 10,264
  • 15
  • 74
  • 143
1
vote
2 answers

Using a dynamic variable binding in a leiningen plugin

I’ve got a lein plugin that manually runs my clojure.test code. It declares a dynamic variable baseuri that I wish to access from within my tests. I’ll strip out and change the code to get straight to the point. Here, inside of my plugin, I have…
Alfred Fazio
  • 956
  • 7
  • 10
1
2