Retired
Basic Statement Coverage in Unit Testing (retired)
86 of 151drchangliu
Loading description...
Fundamentals
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
This shouldn't pass, but it passes.
The reference code in the description is missing the JS version.
It's a pretty interesting kata and unique, that's for sure. The problem is that the description is quite confusing. You should provide some details about how the function should work, that would be much easier to make some tests, that would prove that the implementation is wrong.
Also, in C# tests break, when I call function with null as a parameter, I think you should probably look into that, because the first parameters, that would come to my mind when testing using string as paarameter is string.Empty and null.
Thank you for the invitation. The idea of the kata is very interesting. However, I could not understand what you want me to do. You gave me a piece of code that I think I can run alright. Do you want me to correct that code? Or do you want me to solve some problem. What should I do in my function? What will I return? Neither the explanation nor the tests gave me any idea on what to do. Good luck!
Which language were you working on? I can give you more detailed info if I know which version of the kata you were referring to. Thanks.
Python. Would be gr8 if you do so. Thx
If you click "test", it would fail for the provided template. That's because you need to provide test cases.
From the problem description: "Your function should do all the calls to the count_ballot() function needed to obtain full statement coverage for this function as listed below."
The kata itself is a little disappointing, but I think that is only because the concept is very interesting, and I was hoping for more of a challenge. This one I think is fine for beginners (if a little confusing for what they have to do), but I think this could certainly be a cool kata series of 'unit testing' for progressively harder, more complex testing and functions being tested. I look forward to more!
Thank you for the encouragement. Yes, doing testing is very different. I'm not sure if CodeWars is the right platform for unit tests but it's worth a try.
This comment has been hidden.
https://www.codewars.com/kata/reviews/5faff110c93b4900017ab86e/groups/5fb44c428a65f20001ee7175
You need to remove anything to do with testing from preloaded.
This comment has been hidden.
That's okay I guess
Statement coverage is clearly insufficient. I can follow all code paths without ever testing a ballot that votes for both Biden and Green.
You don't claim statement coverage is sufficient ( or even necessary ), but acknowledging this situation would clarify what it can and can't do.
Thanks for the suggestion. I updated the description to reflect this. You can't cover all statements without testing a ballot that votes for both Biden and Green, though, because there's a "return "INVALID"" statement.
Nyet.
An empty string will test that branch. But that ballot for Green + Biden will result in a vote for Biden ( if I remember correctly ), which shows the inadequacy of this way of testing. Because it should result in invalid, of course.
An empty string covers the "None" case, not the "Invalid" case. "Green + Biden" will indeed become a vote for Biden. That would be a bug but in this case we are only asking for full statement coverage, not a specification-based testing round. In fact, the "full spec" was not provided. Thanks.
Oh sorry, "Trump Biden" tests that branch. I didn't actually look it up and went from memory.
If you insist on bad testing, have at it. Thanks. Unsatisfied. Done.
What is
ballot.lower()
?Note that I'm not American, and don't know about their ballots. Our input is
ballot
. What is that, actually? Does it have a lower half, or can they be lowered, or something? What's the upper half then, and why are we getting it if we are not to test it?In short: specs for
ballot
are incomplete. ( Well, missing. )Function lower() is to turn all letters to lower case so that "Biden" and "biden" can both be matched with the search string "biden".
Paramter ballot is a string that contains the name of the person that one voted for.
Yeah ballot is just a string here, it's mentioned in the code snippet in the description. So .lower() is just Python's lowercase method.
It is now.
Hi,
It's a bit surprising as a kata, but the idea is rather nice. You have several things to take care of:
count_ballot
function, but only to achieve the branching covergage.(This will end up in white level, so you need to be perfectly clear about what happens in the kata)
cheers
Very good suggestions. I updated the description to reflect your points 2 and 3. As for your first point, if I don't put the code in the preloaded part, where should I put it? I can't put in the example test because that's visible to users. I can't put it in the "test cases" section because I assume that means user can't do local test - they will have to click attempt/submit button all the time to reach the function-under-test. I also cannot put it in the complete solution because I assume that means, it's not accessible to users. Any suggestions as to where to hide the function-under-test? Thanks.
Don't resolve issues if you actually didn't handle it completely, plz...
about the tests, you only have to duplicate everything that is in preloaded at the beginning of the test cases: you're passing the function to the user's solution, so you can define it wherever you want. And you keep the version in the preloaded section for the sample tests.
Good idea. Just updated the kata with that. Now this is really resolved. Thanks.
Quick note, I already made the switch but you were still importing the preloaded evaluation function from preloaded, which was causing some silliness where we could just overwrite the evaluation function to make it always 1.