Beta

Write unit-test of simple class

Description
Loading description...
Fundamentals
  • Please sign in or sign up to leave a comment.
  • dfhwze Avatar

    This is not the way to teach anything about testing. I propose you unpublish this kata.

  • playerO1 Avatar

    This comment has been hidden.

  • Voile Avatar

    And anyways, this kata's premise is deeply flawed; hypocritical, even:

    • Unit tests are supposed to test something works reasonably correct. Why are you putting all these instances with pathologically designed behaviours in the tests, and expect us to catch them? Unit tests are not penetration tests, we're not testing if there's a hostile instance that contains a secret backdoor for NSA to hack your private key or something. This would go into manual code reviews. Otherwise you'll be spending eternity testing every combination of a and b in full double-precision float range (which you clearly didn't bother to; you only tested small values of a and b).
    • The order of which result should be returned was never specified, and some tests would hit multiple errors, so what they should return is unspecified too.
    • For the comprehensiveness you ask the user code to write, the test code is actually uninformative and incredibly poorly written. It doesn't even expect a fixed value; it just tests if specific substrings appear in the return result. Why are your test code subjected to such a laughable standard than what we have to write for our test code?
    • Also fix your code, use .includes instead of .indexOf, when sometimes you're testing indexOf(something) > 0 instead of >= 0
  • Voile Avatar

    Description should specify that toString allows a and b to be uppercase.

    Tests doesn't test that f reacts properly to NaN and non-number input values.

  • Voile Avatar

    There are no random tests.

  • Voile Avatar

    There are many similar tests in a single it block with the same failure assertion message, making it impossible to distinguish which sub-test was failed.

    Every it block should do one thing only. If you need to further group the test, nest describe blocks.