I am authoring my first simple Kata on Codewars. The objective of the Kata is to fix the code.
This is the complete working solution,
function yourFutureCareer() {
var career = Math.random();
if (career <= 0.32) {
return 'FrontEnd Developer';
} else if (career <= 0.65) {
return 'BackEnd Developer';
} else {
return 'Full-Stack Developer';
}
}
yourFutureCareer();
This is initial solution the user will work on,
function {
var : Math.random();
if (career <= 0.32) {
return = FrontEnd Developer
else if (career <= 0.65)
return : BackEnd Developer,
} else {
return 'Full-Stack Developer'
}
yourFutureCareer();
In order to publish the Kata, I have to provide Test Cases that will determine if the solution is valid or not. I've tried writing a first Test Case,
Test.assertSimilar(yourFutureCareer(), yourFutureCareer(), 'true')
Sometimes the test fails,
Expected: FrontEnd Developer, instead got: BackEnd Developer
Sometimes the test passes,
Test Passed: Value == Full-Stack Developer
So, how to write test cases so that the solution can be validated? Any example code or sample would be helpful.
Aucun commentaire:
Enregistrer un commentaire