Slimefun4 icon indicating copy to clipboard operation
Slimefun4 copied to clipboard

Actually check if the negative tests do their job

Open Alessio-Colombo opened this issue 1 year ago • 4 comments
trafficstars

Description

While adding tests to #3920 I pushed some tests which would never fail, this fixes them

Proposed changes

Set a flag if the event failure is correctly caught. If not the test has actually failed, so we throw a new exception of our own.

Related Issues (if applicable)

Checklist

  • [ ] I have fully tested the proposed changes and promise that they will not break everything into chaos.
  • [ ] I have also tested the proposed changes in combination with various popular addons and can confirm my changes do not break them.
  • [ ] I have made sure that the proposed changes do not break compatibility across the supported Minecraft versions (1.16.* - 1.20.*).
  • [x] I followed the existing code standards and didn't mess up the formatting.
  • [ ] I did my best to add documentation to any public classes or methods I added.
  • [ ] I have added Nonnull and Nullable annotations to my methods to indicate their behaviour for null values
  • [x] I added sufficient Unit Tests to cover my code.

Alessio-Colombo avatar Dec 12 '23 21:12 Alessio-Colombo

Your Pull Request was automatically labelled as: "✨ Fix" Thank you for contributing to this project! ❤️

github-actions[bot] avatar Dec 12 '23 21:12 github-actions[bot]

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

sonarqubecloud[bot] avatar Dec 12 '23 21:12 sonarqubecloud[bot]

Slimefun preview build

A Slimefun preview build is available for testing! Commit: 5e1334cb

https://preview-builds.walshy.dev/download/Slimefun/4054/5e1334cb

Note: This is not a supported build and is only here for the purposes of testing. Do not run this on a live server and do not report bugs anywhere but this PR!

github-actions[bot] avatar Dec 12 '23 21:12 github-actions[bot]

This works but ima check when I'm on my computer if there is a cleaner way to do this

JustAHuman-xD avatar Dec 12 '23 22:12 JustAHuman-xD

(I may or may not have completely forgot about this, I'd say just go for it since nothing jumps out as better)

JustAHuman-xD avatar Mar 21 '24 18:03 JustAHuman-xD

Actually a much easier way to do this:

Assertions.assertThrows(
    AssertionError.class,
    () -> server.getPluginManager().assertEventFired(TalismanActivateEvent.class, e -> true)
);

WalshyDev avatar Mar 31 '24 12:03 WalshyDev

Walshy chad moment

JustAHuman-xD avatar Mar 31 '24 12:03 JustAHuman-xD

Oh wow, cool trick

Alessio-Colombo avatar Apr 04 '24 18:04 Alessio-Colombo