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

Unit tests for DamageSourceMock #973

Merged
merged 12 commits into from
Feb 22, 2024

Conversation

4everTheOne
Copy link
Contributor

@4everTheOne 4everTheOne commented Feb 22, 2024

Description

Added unit tests for class DamageSourceMock (Related with #479).
This also includes commit 49e2007 which is a fix for pipeline to build.

Checklist

The following items should be checked before the pull request can be merged.

  • Code follows existing style.
  • Unit tests added (if applicable).

@4everTheOne 4everTheOne requested a review from a team as a code owner February 22, 2024 00:11
Copy link
Contributor

@Thorinwasher Thorinwasher left a comment

Choose a reason for hiding this comment

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

Really good that you noticed this! (I was the one that missed adding a testcase for this class).

I have some minor requested changes, but overall good.

@4everTheOne
Copy link
Contributor Author

Hi @Thorinwasher, thank you for the review!

I have migrated the logic from constructor to a method DamageTypeMock#from(JsonObject) in commit 1cb49f0. I think this approach allow us to have the best of both worlds! But let me know your opinion on that :)

Copy link
Contributor

@Thorinwasher Thorinwasher left a comment

Choose a reason for hiding this comment

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

Good idea to with the DamageTypeMock.from(JsonObject) function. Definittely better than using a constructor!

On that, I plan on making a new pull request that applies this on all other keyed objects (but that has to be in a different pull request)

Copy link

sonarcloud bot commented Feb 22, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@4everTheOne
Copy link
Contributor Author

4everTheOne commented Feb 22, 2024

I followed your suggestion , and I think the current state is a good trade-off between complexity and code readability.
This was achieved by converting the information from JSON to a record and replacing the ValueSource with MethodSource.

Copy link
Contributor

@Thorinwasher Thorinwasher left a comment

Choose a reason for hiding this comment

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

Looks good to me

@Thorinwasher Thorinwasher merged commit adc2d6d into MockBukkit:v1.20 Feb 22, 2024
3 checks passed
@4everTheOne 4everTheOne deleted the improve/unit-test-coverage branch February 22, 2024 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants