Fork me on GitHub
#testing
<
2015-09-03
>
meow12:09:53

Does anyone mix unit tests in the same file that they are testing? As opposed to creating a separate test file?

meow12:09:41

I'm wondering if clojure.test and test.check would be useful mixed in?

meow12:09:37

Prior to clojure I worked a lot in Python and always put my unit tests in separate files, but I'm open to change.

meow13:09:53

Or maybe I want to get in the habit of writing a few tests in the same file as I'm doing the development, because its easy, and then later moving those tests out into their own file so they don't clutter up the main module.

meow13:09:25

So my question is as much about workflow as it is about where the tests should ultimately end up.

meow13:09:31

I'm fairly new to clojure and so far I haven't written very many tests and I'm thinking that now is the time to start making the writing of tests part of my process.

meow13:09:30

Devcards, among its many other features, makes a good test runner.

ricardo13:09:58

pkobrien: I don’t - keep them completely separate.

ricardo13:09:02

Not really sure why I’d want to mix them up. I aim to have the smallest file delta possible. If you mix tests and functionality on the same file, you’d end up having to wade through file diffs where only the test changed.

meow13:09:09

@ricardo: Right, that's my usual approach with tests.

meow13:09:11

But some code I was working on recently got me thinking that it might not be bad to through a few tests right into the mix. Partly as tests, but partly as sort of documentation/example/literate programming

meow13:09:48

This is not a new idea by any stretch of the imagination, its just something I've always rejected in the past.

nberger18:09:25

@sdegutis: it depends on the kind of system... But I usually like to start the full system (probably a component/system-map, the same that will be use in production but with config for testing) in every test, and stress it from different angles as a whole... I want to have some of those tests at the very least, apart from tests for specific components or groups of components, so I can be sure the "real system" is being tested...

nberger18:09:45

But that's too broad, were you thinking on a specific kind of system or tests?