testing

Testing tools, testing philosophy & methodology...
seancorfield 2019-07-09T01:19:34.004900Z

@trinity You might want to consider adding https://github.com/clojure-expectations/clojure-test to your project since then you could do

(deftest pangram-1-test
  (testing "is the given string a pangram according to pangram-1 fn?"
    (expect true? (from-each [p pangrams] (pangram-1? p)))
    (expect false? (from-each [n not-pangrams] (pangram-1? n)))))
(edited to correct from-each call after looking at the docs!)

seancorfield 2019-07-09T01:26:29.006900Z

I'd probably write it like this tho'

(defexpect pangram-1-test
  (expecting "is the given string a pangram according to pangram-1 fn?"
    (expect pangram-1? (from-each [p pangrams] p))
    (expect (complement pangram-1?) (from-each [n not-pangrams] n))))

seancorfield 2019-07-09T01:26:55.007400Z

(partly because I prefer the "expect predicate" version of tests mostly)

2019-07-09T01:55:24.008300Z

@aisamu + @seancorfield thanks!! i’ve been writing clojure a few years but only started writing tests in it recently, yr suggestions are much appreciated!

Renan Oliveira 2019-07-09T18:25:27.009900Z

Hi guys, What do you use to integration test? for example, services, controller

seancorfield 2019-07-09T18:41:47.010700Z

I use the same libs as for "unit testing": clojure.test + expectations/clojure-test (to add more expressive assertions to clojure.test).

seancorfield 2019-07-09T18:42:39.011500Z

We also do some integration testing generatively (by generating "known" combinations of actions that should lead to specific observable outcomes).