Add a Random Tests reminder to the Publish button in New Kata editor #2897
benjaminzwhite
started this conversation in
Ideas
Replies: 1 comment
-
I think that would be a really nice addition, for both new and old authors. Also, maybe some random tests could appear with "Insert Example", to help get started: from solution import two_oldest_ages
import codewars_test as test
import random
@test.describe("fixed_tests")
def tests():
@test.it("should return the two oldest ages")
def test_second_oldest_first():
test.assert_equals(two_oldest_ages([1,5,87,45,8,8]), [45, 87])
test.assert_equals(two_oldest_ages([6,5,83,5,3,18]), [18, 83])
@test.describe("random tests")
def rand():
for x in range(100):
lst = [random.randint(1,100) for _ in range(10)]
@test.it(f"Testing for: {lst}")
def _():
# Make sure to separate the expected answer, so the solution doesn't mutate what's being checked!
expected = sorted(lst)[-2:]
test.assert_equals(two_oldest_ages(lst), expected, "Incorrect: ")
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I just noticed while making a translation that if I press "Save" without completing any Solution Setup code, I get an error message: "Setup Code can't be blank" in the top left of the screen - a nice helpful reminder.
I note also that, apart from "duplicate kata", by far the most common reviewer comment on beta katas is the classic "no random tests".
My suggestion therefore is: add a similar pop-up to the Publish button, with a last-minute reminder e.g.:
"A kata should not be published if it is missing random tests. Please make sure you have read this relevant section of the kata authoring documentation or ask for help in the #help-author channel of Codewars Discord if you are unsure about how to build random tests"
One objection might be: "Well users will just type
# random tests xD
in the editor and publish anyway" - I agree, but in that case reviewers would immediately know that they are dealing with someone who is intentionally stupid/misusing the features, rather than a first time author who didn't read the docs properly.Regarding more sophisticated implementation: instead of enabling it by default for all katas, and for all authors, perhaps it could be applied to accounts which have not yet authored a kata? Or perhaps only appear if a quick text-scan of the Tests section does not contain the words "random", "rand", "seed" etc or whatever the name of the needed
random
module is in the given kata language?Beta Was this translation helpful? Give feedback.
All reactions