Manchester | 26-ITP-May | Szidonia Bodo | Sprint 3 | Implement and review test - #1520
Manchester | 26-ITP-May | Szidonia Bodo | Sprint 3 | Implement and review test#1520bodoszidi wants to merge 12 commits into
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| assertEquals(isProperFraction(-8, 2), false); | ||
| assertEquals(isProperFraction(4, 0), false); | ||
| assertEquals(isProperFraction(0, 0), false); | ||
| assertEquals(isProperFraction(-2, -2), false) |
There was a problem hiding this comment.
If you were to check the case of isProperFraction(-1, 2), what do we want to see as the answer? And would that test pass?
(Things get a little awkwardly mathsy with negative fractions, I recognise)
There was a problem hiding this comment.
Since the function requires the numerator to be greater than 0, a negative numerator should return false.
The test isProperFraction(-1, 2) would pass because numerator > 0 will return false.
| assertEquals(getCardValue("J♦"), 10); | ||
| assertEquals(getCardValue("7♥"), 7); | ||
| assertEquals(getCardValue("A♥"), 11); | ||
| assertEquals(getCardValue("8♥"), 8); |
There was a problem hiding this comment.
When writing a test suite, we want to try and cover all possible "behaviours" of our function. Here I can see you've covered:
- Hearts
- Spades
- Diamonds
- Numbered cards
- Jacks
- Aces
Looking at that list, what have you not covered?
There was a problem hiding this comment.
I haven't covered Clubs (♣) or the other face cards (Q and K). Although they are handled by the same logic as Jacks, adding test cases for them would improve coverage and help catch any mistakes in those specific conditions.
There was a problem hiding this comment.
Still looks like there's one suit we haven't covered yet 👀
There was a problem hiding this comment.
Added the missing suit and new test cases.
|
|
||
| test(`should return false when denominator is bigger than the numerator`, () => { | ||
| expect(isProperFraction(5, -2)).toEqual(false); | ||
| expect(isProperFraction(-1, 0)).toEqual(false); |
There was a problem hiding this comment.
expect(isProperFraction(-1, 0)).toEqual(false);
This test case, which test does it belong in? What grouping of behaviours does it fall into?
There was a problem hiding this comment.
Should be in a different case to test negative numbers - updated the test file.
There was a problem hiding this comment.
Two things:
- I think there is an earlier test description that really best describes the
isProperFraction(-1, 0)case! - Numerator/denominator being negative technically doesn't determine whether a fraction is proper or improper. For example,
isProperFraction(-2, 5)should actually betruebecause2is smaller than5. How you could account for this?
|
Hey @bodoszidi! 👋 Good work on your first journey into using tests. Writing tests from scratch is not easy, it's a skill that takes a while to develop but there's a lot of good stuff in here. My comments are mostly about focussing on how to organise our test cases. The main things we want to be doing are:
Please do respond to any comments with answers or further questions if you aren't sure what I'm talking about! 😄 |
Removed redundant comments from test cases for clarity.
…ional tests Refactor variable declaration to use const for removeSuit and add test cases for Queen and King.
Added a test case to check for proper fraction with positive numbers.
|
@bodoszidi Good improvements! Just a couple of lingering comments around handling negative fractions 🙂 |
Self checklist
Changelist
Created a new pull request only for implementation and review test