Ad
  • Default User Avatar

    Thanks for taking the time to answer. I'm a newcomer at Codewars so I probably need to tune in with the philosophy. That said, I don't understand why people would want to cheat the solutions (maybe to show a "strong" profile in a job interview?). In the end they are lying to themselves.

  • Default User Avatar

    Nothing better than delegating on the standard libraries! ;)

  • Custom User Avatar

    Reading the first post I don't get that. About all you said, I agree too, fixed tests should be complete including edge case tests and random tests should be used only to avoid hardcoding solutions.

    If what you said was the OP's intent, then asking for better fixed tests should have been there instead of asking for random tests being forbidden or justified.

  • Custom User Avatar

    What I take from OPs complaint is that "main" tests should be fixed tests, which should fail an incorrect solution consistently and repeatably, and potential issues with user solution should be found by fixed tests and not only by random tests. If this is what the OP means, then I completely agree. In many, many kata, and I think that it's a general authoring practice, fixed tests are neglected and all testing of coverage, and of edge cases, is expected to be done by random tests. Tests which, in turn, are often not even designed with coverage in mind, just spray a bunch of random data around hoping to hit something .

    Codewars needs random tests mainly to prevent hardcoding. Random tests can also serve as a replacement for property-based random testing, sure. But in vast amount of cases it's neither. It's usually just three lousy fixed tests and a random spray which is hoped to be as complete as possible, but in practice it might, or might not, verify correctness of a user solution, depending on a random chance. And even if it does find problems with a user solution, it's done in a way which is not always helpful. Whenever possible, it should not be only random tests which fail when a solution is wrong.

  • Custom User Avatar

    Sorry but I don't see your point against random tests, if your code is fine, it should pass them with no problem. Do random test cover all possibilities? No, they don't, they sometimes generate edge cases, and those should be part of fixed tests too to ensure good tests coverage. About repeatability, read Madjosz answer, it tells you how you can repeat a random test your code failed. Also read this: https://docs.codewars.com/training/troubleshooting#print-input

    Without random tests all katas could be solved with if/else, do you think that would be fine?

  • Default User Avatar

    OK, I know this is not strict unit testing, but using random data to validate solutions might leave room for incompleteness (either the solution or the validation code).
    Fraud can come in a wide variety of forms (copy-pasting from other sites, hardcoding results, AI generated solutions...). Should the katas codebase quality be impacted because of this?
    Regulatory measures should be separated from the kata's logic. Otherwise, in the long run, the code base will be formed with (in this case) a lot of non-repeatable tests (which, IMHO, is not very high-quality code, so to say :) ).
    Perhaps users should have the means to mark other's solutions as "hardcoded", with an impact on "honor".

  • Custom User Avatar

    Random tests are there so you can't hardcode your solution. For repeatability you have fixed tests.

  • Default User Avatar

    Random tests defeat one of the main purposes of testing: repeatability. Codewars should forbid use of random tests (unless VERY well justified). In this specific kata I don't see the justification at all.