• xorium (unregistered)

    Looks to me like this will fail if any exception is thrown by "centralizedLogger.logAround(joinPoint);"

  • some guy (unregistered) in reply to xorium

    One would hope that an uncaught exception would fail the test no matter what BS is or isn't asserted down the line.

  • (nodebb) in reply to some guy

    Perhaps that's entirely the point. Yes, it's 137% totally obscure, especially without comments, but ...

  • (nodebb)

    It is possible that my short tenure at a major financial firm was due to me informing my manager that although our "code coverage" was over 90% there were no assert statements.

  • (nodebb)

    Cobra effect. Anything you require, no matter how stupid, will be accomplished in the easiest possible way.

  • (nodebb)

    Bonus points for annotating the instance variable centralizedLogger with @InjectMocks - it won't mock anything since there is no other mocked instance injected - and then just overwriting that same variable in the method with a new ContralizedLogger instance.

  • Rob (unregistered) in reply to Rick

    SonarQube complains if a unit test does not have any assertions. Sometimes you just want to test that a piece of code doesn't throw any exceptions. You can use assertDoesNotThrow(() -> /* code as lambda or method reference */) for that. It's of course possible to fool SonarQube and just wrap the entire test method in assertDoesNotThrow.

Leave a comment on “Cover Up”

Log In or post as a guest

Replying to comment #691186:

« Return to Article