-
Notifications
You must be signed in to change notification settings - Fork 279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test naming inconsist with function naming. #255
Comments
The function is Whilst it is true there is no need to follow any specific naming code for tests, encouraging folks to write a dedicated test for each function Note that some test runners assume that tests are in namespaces with a |
I think you are confusing tradition with consistency. Consistency is: All things are post-fixed with the thing they are. Tradition is: some things are post-fixed others are not, because we always have done it that way, and we still do this even when there is no reason to do this. Furthermore, the test With It is true that in the case where the test file does a The point I want to make is that it should not be 'mandatory' to always postfix test functions with (I am not talking about namespace naming, as you correctly pointed out, there is a technical reason.) |
Tests should have a different name from the function that they are testing, if only for the reason that
These guidelines are part of the Clojure style guide, which documents generally accepted practices and conventions in the Clojure community. As far as I can tell, the currently documented policies match the community consensus. If you don't like them, you don't have to use them though. See the note about consistency which acknowledges that you should still use your best judgement. If your best judgement is to not use |
I agree with you, however, often best judgement is cudgeled by a 'the styleguide says'. Of course, we should give different things different names, to avoid name clashes, but that is not limited to tests. Scoping issues also happen in a Currently the styleguide says:
So why is there this hard distinction for tests, but not for other items that can cause scoping issues? |
The guide advises to name tests:
(deftest foo-test ...)
But functions as
(defn foo ...)
Shouldn't it be:
(defn foo-function ...)
to be consistent?
However, there is no need postfix testnames with
-test
, since the tests are marked in their meta-data, and the test runner can locate them this way. Clojure does not locate tests by name, such as is the case in Python and Javascript, for example, where this is required.The text was updated successfully, but these errors were encountered: