Facts and implementation in the same file

15 views
Skip to first unread message

Tamas Herman

unread,
Dec 21, 2015, 4:26:22 PM12/21/15
to Midje
Are there any serious drawback of having the facts right next to the implementation?

What are the benefits of having them in a parallel test namespace structure?

If we are talking about integration tests then it's not a question of course,
but for unit tests it seems to avoid a context switch between 2 files and
halves the number of files in the project.

-- 
  tom

Sam Ritchie

unread,
Dec 21, 2015, 4:35:01 PM12/21/15
to mi...@googlegroups.com
if you keep your tests in the same file for, say, a webapp, the test suite will run when you launch the app and first require each namespace. If you keep code in a separate “test” root you can exclude all of those files when you deploy your library to clojars or your code to production.

Sam Ritchie (@sritchie)
Machine Learning @ Stripe
samritchie.io | 703.863.8561



--
You received this message because you are subscribed to the Google Groups "Midje" group.
To unsubscribe from this group and stop receiving emails from it, send an email to midje+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Brian Marick

unread,
Dec 21, 2015, 4:58:10 PM12/21/15
to mi...@googlegroups.com


Tamas Herman wrote:
> Are there any serious drawback of having the facts right next to the
> implementation?

I used to have tests and code in the same source, but now I follow the
conventional separation (`/test` and `/src`) for these reasons:

1. Tools expect it, and they get confused or unusable without it.

2. People expect it, and they tend to be put off by seeing something
different.

3. I actually find the context switching between code and test more
difficult when they're in the same file. That's because I have fixed
Emacs windows for the code and test, so the switch less often requires
scrolling. My layout is described here:
http://about.getset.com/developer-blog/2014/12/1/my-clojure-micro-workflow

Brian Marick

unread,
Dec 21, 2015, 5:07:51 PM12/21/15
to mi...@googlegroups.com


Sam Ritchie wrote:
> if you keep your tests in the same file for, say, a webapp, the test
> suite will run when you launch the app and first require each namespace.

You can turn that off: https://github.com/marick/Midje/wiki/Production-mode
Reply all
Reply to author
Forward
0 new messages