# Spec instrumentation only checks fdef :args?

**URL:** https://clojureverse.org/t/spec-instrumentation-only-checks-fdef-args/11018
**Category:** Beginners
**Tags:** clojure\_spec
**Created:** [November 18, 2024, 12:27am UTC](https://clojureverse.org/t/spec-instrumentation-only-checks-fdef-args/11018 "2024-11-18T00:27:31Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![darrenaustin](https://clojureverse.org/user_avatar/clojureverse.org/darrenaustin/32/5581_2.png) [@darrenaustin](https://clojureverse.org/u/darrenaustin)
#### Post date: [November 18, 2024, 12:27am UTC](https://clojureverse.org/t/spec-instrumentation-only-checks-fdef-args/11018/1 "2024-11-18T00:27:31Z")

</div>

Hey folks,

Sorry if this has been answered elsewhere (in which case, please point me in the right direction), but why doesn’t `clojure.spec.test.alpha/instrument` test anything other than the `:args` of an `fdef`?

I was hoping to use instrumentation to replace specifying `:pre` and `:post` conditions on functions. Instrumentation would give a finer grain control over when I take a performance hit for validation, as I would only have to turn it on for functions I care about during dev.

However, it appears it doesn’t check the `:ret` or `:fn` params of the `fdef`. I know these can be useful for generating test data, but that isn’t very helpful for my use case.

Or am I just missing something?

Thanks,  
–Darren

---

<div class="post-metadata">

### Author: ![seancorfield](https://clojureverse.org/user_avatar/clojureverse.org/seancorfield/32/195_2.png) [@seancorfield](https://clojureverse.org/u/seancorfield)
#### Post date: [November 18, 2024, 4:10am UTC](https://clojureverse.org/t/spec-instrumentation-only-checks-fdef-args/11018/2 "2024-11-18T04:10:44Z")

</div>

That’s a frequently asked question: [Clojure - Frequently Asked Questions - Why doesn’t `instrument` check return values?](https://clojure.org/guides/faq#instrument_ret)

---

<div class="post-metadata">

### Author: ![seancorfield](https://clojureverse.org/user_avatar/clojureverse.org/seancorfield/32/195_2.png) [@seancorfield](https://clojureverse.org/u/seancorfield)
#### Post date: [November 18, 2024, 4:18am UTC](https://clojureverse.org/t/spec-instrumentation-only-checks-fdef-args/11018/3 "2024-11-18T04:18:15Z")

</div>

This blog post I wrote a while back might give you some more background on Spec and the various ways it can be used, based on how it is designed to be used:

[An Architect’s View: How do you use clojure.spec](https://corfield.org/blog/2019/09/13/using-spec/)

At work, we were a fairly early adopter, and tried to follow the design guidelines as much as possible.

One area where we diverged was to rely on Spec for value coercion as part of conforming and validation. We began to regret this decision after a few years but haven’t fully extricated ourselves from that! A caution against trying to swim upstream by “abusing” the intended design of a feature that Rich et al have spent a lot of time thinking about.

---

<div class="post-metadata">

### Author: ![darrenaustin](https://clojureverse.org/user_avatar/clojureverse.org/darrenaustin/32/5581_2.png) [@darrenaustin](https://clojureverse.org/u/darrenaustin)
#### Post date: [November 18, 2024, 5:28am UTC](https://clojureverse.org/t/spec-instrumentation-only-checks-fdef-args/11018/4 "2024-11-18T05:28:08Z")

</div>

Thanks for the info and the pointers. Sorry I missed that in my search.

---

<div class="post-metadata">

### Author: ![ryantate](https://clojureverse.org/user_avatar/clojureverse.org/ryantate/32/4162_2.png) [@ryantate](https://clojureverse.org/u/ryantate)
#### Post date: [November 26, 2024, 5:41am UTC](https://clojureverse.org/t/spec-instrumentation-only-checks-fdef-args/11018/5 "2024-11-26T05:41:15Z")

</div>

On a practical level, you can use orchestra to check :ret specs (and other fdef specs). Old but still works fine. [GitHub - jeaye/orchestra: Complete instrumentation for clojure.spec](https://github.com/jeaye/orchestra)

Although one big annoyance is the error wording is the exact same as for when the input args are wrong, you just have to figure out it is referring to the output being wrong.

Apparently you can do so by examining the data in the failure and/or using a companion library [Exception no longer mentions source? (:args, :ret) · Issue #51 · jeaye/orchestra · GitHub](https://github.com/jeaye/orchestra/issues/51)

---

<div class="post-metadata">

### Author: ![system](https://clojureverse.org/uploads/default/original/2X/5/51079bf9e4b7d9466242c06cf1e43b9f8bd6da14.png) [@system](https://clojureverse.org/u/system)
#### Post date: [November 10, 2025, 5:04pm UTC](https://clojureverse.org/t/spec-instrumentation-only-checks-fdef-args/11018/7 "2025-11-10T17:04:18Z")

</div>

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