Skip to content

Commit c6da55e

Browse files
committed
Add a section on test naming
Closes bbatsov#131.
1 parent b76f79b commit c6da55e

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ Translations of the guide are available in the following languages:
5151
* [Comment Annotations](#comment-annotations)
5252
* [Existential](#existential)
5353
* [Tooling](#tooling)
54+
* [Testing](#Testing)
5455

5556
## Source Code Layout & Organization
5657

@@ -1639,6 +1640,36 @@ in your endeavor to write idiomatic Clojure code.
16391640
search for patterns of code for which there might exist a more idiomatic
16401641
function or macro.
16411642
1643+
## Testing
1644+
1645+
* <a name="test-directory-structure"></a>
1646+
Store your tests in a separate directory, typically `test/yourproject/` (as
1647+
opposed to `src/yourproject/`). Your build tool is responsible for making
1648+
them available in the contexts where they are necessary; most templates
1649+
will do this for you automatically.
1650+
<sup>[[link](#test-directory-structure)]</sup>
1651+
1652+
* <a name="test-ns-naming"></a>
1653+
Name your ns `yourproject.something-test`, a file which usually lives in
1654+
`test/yourproject/something_test.clj` (or `.cljc`, `cljs`).
1655+
<sup>[[link](#test-ns-naming)]</sup>
1656+
1657+
* <a name="test-naming"></a> When using `clojure.test`, define your tests
1658+
with `deftest` and name them `something-test`. For example:
1659+
1660+
```clojure
1661+
;; good
1662+
(deftest something-test ...)
1663+
1664+
;; bad
1665+
(deftest something-tests ...)
1666+
(deftest test-something ...)
1667+
(deftest something ...)
1668+
```
1669+
1670+
<sup>[[link](#test-naming)]</sup>
1671+
1672+
16421673
# Contributing
16431674
16441675
Nothing written in this guide is set in stone. It's my desire to work

0 commit comments

Comments
 (0)