Warning: Declaration of LJXP_Walker_Category_Checklist::start_lvl(&$output, $depth, $args) should be compatible with Walker::start_lvl(&$output, $depth = 0, $args = Array) in /home/victorsergienko/victorsergienko.com/wp-content/plugins/lj-xp/lj-xp-options.php on line 796

Warning: Declaration of LJXP_Walker_Category_Checklist::end_lvl(&$output, $depth, $args) should be compatible with Walker::end_lvl(&$output, $depth = 0, $args = Array) in /home/victorsergienko/victorsergienko.com/wp-content/plugins/lj-xp/lj-xp-options.php on line 796

Warning: Declaration of LJXP_Walker_Category_Checklist::start_el(&$output, $category, $depth, $args) should be compatible with Walker::start_el(&$output, $object, $depth = 0, $args = Array, $current_object_id = 0) in /home/victorsergienko/victorsergienko.com/wp-content/plugins/lj-xp/lj-xp-options.php on line 796

Warning: Declaration of LJXP_Walker_Category_Checklist::end_el(&$output, $category, $depth, $args) should be compatible with Walker::end_el(&$output, $object, $depth = 0, $args = Array) in /home/victorsergienko/victorsergienko.com/wp-content/plugins/lj-xp/lj-xp-options.php on line 796

Warning: Cannot modify header information - headers already sent by (output started at /home/victorsergienko/victorsergienko.com/wp-content/plugins/lj-xp/lj-xp-options.php:796) in /home/victorsergienko/victorsergienko.com/wp-content/plugins/wp-super-cache/wp-cache-phase2.php on line 60
code name / Why I don’t like GMock
Skip to content

Why I don’t like GMock


I don’t like GMock.

It’s not as if it was badly written or designed. But it lets you to unit-test dirtier code, tying to method call structure instead of resulting data.

For instance, this GMock code can be rewritten:

        loggingService.sendNotification(match{ !it.shouldNotify() }).stub()
        loggingService.sendNotification(match {
            it.shouldNotify() && it instanceof HubOfflineNotification && it.deadEntities == [hub]
        })
        loggingService.saveEvent(LogEventType.HUB_BECAME_OFFLINE, match { it }, customer)
        loggingService.saveEvent(LogEventType.CAMERA_DIED, match { it }, customer).never()

        play {
            loggingService.reportHealth(diff)
        }

to:

        eventLogService.reportHealthDiff(diff)

        assertEquals 1, LogEvent.countByEventType(LogEventType.AGENT_BECAME_OFFLINE)
        assertEquals 0, LogEvent.countByEventType(LogEventType.METER_BECAME_DEAD)
        assertEquals 1, LogEvent.countByEventType(LogEventType.SENDING_NOTIFICATION)

which relies only to call outcome, and not to implementation details.

Post a Comment

Your email is never published nor shared.