

Ask HN: assertEquals, assertEqual, or assert_equal? - vlisivka

Which variant I should use in my own unit-testing library for bash? I using assertEqual now, but I saw both assertEquals (shunit) and assert_equal (bash-unit).<p>English is foreign language for me, so it is hard to decide. :-/
======
gharbad
camelCase vs. underscore_delimited is really a religious preference: use
whatever the people you're working with are using..

as far as equal vs. equals: both make sense, but I would favor 'equal' exactly
because of this. I don't feel there is a need to constantly add a frivolous
character to all of your statements.

------
nantes
In my experience, with SimpleTest in PHP and unittest2 in Python,
assertEqual() seem to be the convention.

Indeed, in unittest2, both assertEquals() and assert_equal() both appear to be
deprecated in favor of assertEqual().

------
stonemetal
It depends on how you read the code. Equals is the singular and would read as
"I assert A equals B". Equal is the plural and would read as " I assert A and
B are equal". I tend to think the second phrase, but both are correct from an
English standpoint.

~~~
jonafato
This is a nitpick, but "A equals B" uses the verb "equals", and "A and B are
equal" uses the adjective "equal", describing a state of being. That said,
reading code like English would probably suggest something like
assertEqual(A,B) or A.assertEquals(B). At the end of the day, it's all just
what looks best to you.

