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

[Core] Improve checks in blood tests #245

Merged
merged 5 commits into from
Jan 6, 2021

Conversation

anubisthejackle
Copy link

What is the reason for this PR?

To improve the test suite around blood tests so it fails should any blood type, or RH, not be present. Previously it would pass if any blood type and RH were present. Now all must exist.

Author's checklist

Summary of changes

I've updated the Blood Test suite inline with how tests are handled in en_US/PersonTest regarding randomized data. I don't believe this is a perfect solution, but it does correct the potential issue where breaking changes in the Blood class did not break the tests.

Review checklist

  • All checks have passed
  • Changes are approved by maintainer

@codecov
Copy link

codecov bot commented Jan 3, 2021

Codecov Report

Merging #245 (1e705c1) into main (cd8a4a5) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##               main     #245   +/-   ##
=========================================
  Coverage     58.52%   58.52%           
  Complexity     2050     2050           
=========================================
  Files           316      316           
  Lines          5119     5119           
=========================================
  Hits           2996     2996           
  Misses         2123     2123           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cd8a4a5...1e705c1. Read the comment docs.

@GrahamCampbell
Copy link
Member

Why should 100 random runs always contain every blood type?

@anubisthejackle
Copy link
Author

@GrahamCampbell I can't confirm that they will on every architecture, thus my comment about it not being the best possible method, but with the seeding it is at least consistent, and accurate when all are present in the run.

I don't know the math off the top of my head, but there is a set size where it is improbable to the point of near impossibility that we don't get at least one of each in the result set. 100 worked on my machine so I didn't expand it beyond that -- for the sake of speed.

In a perfect world we would be able to inject / overload the helper. I fear the reliance on so many static methods makes that difficult without re-architecting a large portion of the project.

Basically: I went with good enough, with the hopes that the discussion around 2.0 will improve things even further.

@IonBazan
Copy link

IonBazan commented Jan 4, 2021

@anubisthejackle We would need to refactor all the tests in similar way which is reported in #125 and partially solved in #134

@anubisthejackle
Copy link
Author

@anubisthejackle We would need to refactor all the tests in similar way which is reported in #125 and partially solved in #134

I agree.

This PR really just attempts to reflect the comments @localheinz made on the original PR regarding these specific tests.

@bram-pkg bram-pkg changed the title Improve checks in blood tests [Core] Improve checks in blood tests Jan 5, 2021
@pimjansen
Copy link

@localheinz can you jump in here as well? Is this really the best way to do it?

Overall there will never be a 100% solution with these data lists though so

@pimjansen pimjansen added the enhancement New feature or request label Jan 5, 2021
@anubisthejackle
Copy link
Author

@localheinz can you jump in here as well? Is this really the best way to do it?

Overall there will never be a 100% solution with these data lists though so

The best way to do it would be to be able to inject a randomization algorithm that we control that would allow us to force random methods to non-random for tests. Seeding does a good job of that, but it's still random. We can work with the number in the loop to find the smallest set that contains all the items required, but this requires tweaking if we ever have to add items. (Not really an issue here with blood types...how often do we add new blood types?)

That's my 2 cents on that anyway.

@pimjansen
Copy link

Wel they cant so even 100 is much imo. Cant we say for example that we run x iterations for the amount of possible values with a max of y?

In this case we have like 8 options so lets say 24 iterations will do?

No idea if times 3 is a valid number but what are the ideas?

@anubisthejackle
Copy link
Author

@pimjansen Tested locally just now and I've updated the loop counts so they pass locally. I'm assuming this will translate to consistently passing elsewhere, but I'm never 100% certain about randomization and seeding on different machines.

@localheinz localheinz self-requested a review January 6, 2021 11:15
@anubisthejackle
Copy link
Author

@localheinz Updates made. That will definitely help to keep those tests from growing too far.

@localheinz localheinz self-assigned this Jan 6, 2021
Copy link
Member

@localheinz localheinz left a comment

Choose a reason for hiding this comment

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

👍

@localheinz localheinz merged commit d426295 into FakerPHP:main Jan 6, 2021
@localheinz
Copy link
Member

Thank you, @anubisthejackle!

@anubisthejackle anubisthejackle deleted the improve-blood-test-suite branch January 6, 2021 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants