When a mock call doesn't meet its expecation, the error is put on stdout during the call. So when this code happens: var=$(mocked-command) then $var has the error "Unexpected call..." so it's hard to debug and see the problem