testing

Testing tools, testing philosophy & methodology...
metametadata 2016-08-16T10:19:00.000063Z

@abarylko extracting a helper function (`test-get-res-with-pagination`) looks totally OK to me in most cases. This approach only becomes a problem when you have lots of the same deftests which you need to call for another endpoint. E.g. when you also have to test the same behavior not only about paging, but also about authorization, caching and logging. As in: you've written a suite of 50 deftests for customers and now want to reuse the suite for houses. I've encountered such scenario but didn't find a good solution at the time. I extracted a parametrized test-...-contract function with multiple testing clauses in it and called this function within a deftest for each thing I wanted to conform to such contract. The potential drawback is that such test suite will "short-circuit" in case of an exception thrown outside of is clauses. Here's an example of my contract function: https://github.com/metametadata/clj-fakes/blob/71ed5225ebb7974b2a4e70b137effe03388a3d52/test/unit/fake_fn_contract.cljc#L14 And how I reuse it in two places: 1. https://github.com/metametadata/clj-fakes/blob/71ed5225ebb7974b2a4e70b137effe03388a3d52/test/unit/fake.cljc#L17 2. https://github.com/metametadata/clj-fakes/blob/71ed5225ebb7974b2a4e70b137effe03388a3d52/test/unit/recorded_fake.cljc#L35

roberto 2016-08-16T16:20:35.000066Z

is there a lein plugin for test reports? Currently the result of a test looks something like this:

Ran 22 tests containing 43 assertions.
2 failures, 1 errors.
Tests failed.

roberto 2016-08-16T16:21:19.000067Z

but I’d like to see something like this:

Ran 22 tests containing 43 assertions.
2 failures, 1 errors.
Tests failed.

x.y.z/first-test failed
x.y.w/second-test failed

roberto 2016-08-16T16:21:40.000068Z

instead of having to scroll up and find the failing tests. This is cumbersome when there are log statements.

jakemcc 2016-08-16T16:56:25.000069Z

@roberto: Not sure if one exists, but you can write your own by supplying your own defmethod for the report multi-method. multi-method: https://github.com/clojure/clojure/blob/master/src/clj/clojure/test.clj#L324 example of changing output: https://github.com/clojure/clojure/blob/master/src/clj/clojure/test/junit.clj

jakemcc 2016-08-16T16:57:27.000071Z

@roberto: you would probably need to supply a new :fail and :summary method

abarylko 2016-08-16T19:27:55.000072Z

Thanks @metametadata ! I’ll take a look, I was wondering if using a macro to generate the common test cases would be a good idea…...