# How to minimize redundancy between unit testing and spec?

**URL:** <https://clojureverse.org/t/how-to-minimize-redundancy-between-unit-testing-and-spec/3152>\
**Category:** How to?\
**Tags:** testing, clojure\_spec\
**Created:** [November 9, 2018, 1:05pm UTC](https://clojureverse.org/t/how-to-minimize-redundancy-between-unit-testing-and-spec/3152 "2018-11-09T13:05:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Webdev\_Tory](https://clojureverse.org/user_avatar/clojureverse.org/webdev_tory/32/3781_2.png) [@Webdev\_Tory](https://clojureverse.org/u/Webdev_Tory)\
**Post date:** [November 9, 2018, 1:05pm UTC](https://clojureverse.org/t/how-to-minimize-redundancy-between-unit-testing-and-spec/3152/1 "2018-11-09T13:05:05Z")

</div>

I can write a unit test for a function. I can also write an fdef for pre/post-conditions. There seems to be a lot of overlap in what I end up with; should I avoid one or the other? I guess it’s spec that seems like the first one to cut out, since unit tests play so nicely with cider/testing tooling. Do you have a clean workflow that leverages both of these?

---

<div class="post-metadata">

**Author:** ![DjebbZ](https://clojureverse.org/user_avatar/clojureverse.org/djebbz/32/531_2.png) [@DjebbZ](https://clojureverse.org/u/DjebbZ)\
**Post date:** [November 9, 2018, 9:36pm UTC](https://clojureverse.org/t/how-to-minimize-redundancy-between-unit-testing-and-spec/3152/2 "2018-11-09T21:36:52Z")

</div>

> [@Webdev\_Tory](#):
>
> that leverages both of these?

Not exactly both of these, but generative testing with test.check and clojure.spec is a killer combo. I’m using it successfully in a very important internal library where bugs must be avoided at all costs, and it’s giving me great confidence that it works fine where tests are green. Much greater than example based testing alone.

---

<div class="post-metadata">

**Author:** ![system](https://clojureverse.org/uploads/default/original/2X/5/51079bf9e4b7d9466242c06cf1e43b9f8bd6da14.png) [@system](https://clojureverse.org/u/system)\
**Post date:** [May 11, 2019, 9:36am UTC](https://clojureverse.org/t/how-to-minimize-redundancy-between-unit-testing-and-spec/3152/3 "2019-05-11T09:36:56Z")

</div>

Closed on May 11, 2019, 9:36am UTC

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.
