Ad
  • 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?

  • Custom User Avatar

    If your concern is that you are failing different tests all the time then capture the inputs and expected outputs and put them into your sample tests.

  • Custom User Avatar

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