Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Garment Size Test Tweak #657

Merged
merged 1 commit into from
Jan 30, 2023
Merged

Garment Size Test Tweak #657

merged 1 commit into from
Jan 30, 2023

Conversation

kingthorin
Copy link
Collaborator

Check the the value returned is one of the expected values, vs just not empty.

Signed-off-by: kingthorin kingthorin@users.noreply.github.com

Check the the value returned is one of the expected values, vs just not
empty.

Signed-off-by: kingthorin <kingthorin@users.noreply.github.com>
@what-the-diff
Copy link

what-the-diff bot commented Jan 30, 2023

  • Added import statement for List
  • Changed method name from size() to testSize()
  • Created a new private method getActualSizes(), which returns the list of garment sizes as defined in garments_sizes.yml file, and used it instead of calling faker directly inside testSize(). This is done so that we can use this same list later on when testing other methods like randomElementFromListOfGarmentSizes().
  • Updated assertion logic to check if generated value matches any element in actual values returned by getActualSizes() call above (instead of just checking if its not empty).

assertThat(faker.garmentSize().size()).isNotEmpty();
void testSize() {
// Given
List<String> actualSizes = getActualSizes();
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had considered doing this as:

List<String> actualSizes = List.of("XS", "S", "M", "L", "XL", "XXL", "XXXL");

Since it's likely always a small set of values, but I kept waffling back and forth. So let me know which form you like better.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I just realized that List.of wouldn’t have been good for your Java 8 support. Still coulda declared it more inline’ishly.

@kingthorin
Copy link
Collaborator Author

I'm sure there's lots of testing that could be more specific like this. This one just caught my eye for some reason. If this is merged I'm happy to tackle more.

@codecov-commenter
Copy link

Codecov Report

Merging #657 (37ba7d8) into main (d57cc7c) will increase coverage by 0.04%.
The diff coverage is n/a.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@             Coverage Diff              @@
##               main     #657      +/-   ##
============================================
+ Coverage     92.73%   92.77%   +0.04%     
- Complexity     2623     2626       +3     
============================================
  Files           281      281              
  Lines          5397     5415      +18     
  Branches        589      589              
============================================
+ Hits           5005     5024      +19     
- Misses          241      242       +1     
+ Partials        151      149       -2     
Impacted Files Coverage Δ
...c/main/java/net/datafaker/providers/base/Text.java 77.96% <0.00%> (-0.85%) ⬇️
...net/datafaker/transformations/JsonTransformer.java 92.92% <0.00%> (+0.28%) ⬆️
...n/java/net/datafaker/providers/base/BaseFaker.java 88.69% <0.00%> (+0.86%) ⬆️
...ker/idnumbers/pt/br/IdNumberGeneratorPtBrUtil.java 96.29% <0.00%> (+3.70%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@bodiam
Copy link
Contributor

bodiam commented Jan 30, 2023

Hi @kingthorin , there's quite a few tests which hardly test anything, so this is a great contribution, thank you!

@bodiam bodiam merged commit 9b7ffd8 into datafaker-net:main Jan 30, 2023
@kingthorin kingthorin deleted the size-test branch January 30, 2023 10:18
@kingthorin kingthorin mentioned this pull request Jan 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants