{"action":"created","issue":{"url":"https://api.github.com/repos/dart-lang/mockito/issues/47","repository_url":"https://api.github.com/repos/dart-lang/mockito","labels_url":"https://api.github.com/repos/dart-lang/mockito/issues/47/labels{/name}","comments_url":"https://api.github.com/repos/dart-lang/mockito/issues/47/comments","events_url":"https://api.github.com/repos/dart-lang/mockito/issues/47/events","html_url":"https://github.com/dart-lang/mockito/issues/47","id":196535737,"number":47,"title":"Friendly debug messages when mock methods without expectations set are called.","user":{"login":"renning22","id":4597657,"avatar_url":"https://avatars.githubusercontent.com/u/4597657?v=3","gravatar_id":"","url":"https://api.github.com/users/renning22","html_url":"https://github.com/renning22","followers_url":"https://api.github.com/users/renning22/followers","following_url":"https://api.github.com/users/renning22/following{/other_user}","gists_url":"https://api.github.com/users/renning22/gists{/gist_id}","starred_url":"https://api.github.com/users/renning22/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/renning22/subscriptions","organizations_url":"https://api.github.com/users/renning22/orgs","repos_url":"https://api.github.com/users/renning22/repos","events_url":"https://api.github.com/users/renning22/events{/privacy}","received_events_url":"https://api.github.com/users/renning22/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-12-19T22:21:54Z","updated_at":"2016-12-28T20:01:34Z","closed_at":null,"body":"For example:\r\n```\r\n//Real class\r\nclass Cat {\r\n  String sound() => \"Meow\";\r\n}\r\n\r\n//Mock class\r\nclass MockCat extends Mock implements Cat {}\r\n\r\n//mock creation\r\nvar mockCat = new MockCat();\r\n\r\n// Would throw exception \"NoSuchMethodError: The method 'toUpperCase' was called on null.\".\r\nmockCat.sound().toUpperCase();\r\n```\r\n\r\nThe actual cause is during the test development, developer forgot to write \"when(cat.sound()).thenReturn(\"Purr\");\".\r\n\r\nThe message \"'toUpperCase' was called on null\" isn't helpful for finding out the casue and a more friendly message could be \"'toUpperCase' was called on the return value of 'Cat.sound()', but no exceptions were set on it\".\r\n\r\nThis could be achieved by returning instead of 'null' but a special object carrying the method invocation information for any 'un-expected' methods.\r\n\r\nI can come with a design doc if this sounds possible."},"comment":{"url":"https://api.github.com/repos/dart-lang/mockito/issues/comments/269532366","html_url":"https://github.com/dart-lang/mockito/issues/47#issuecomment-269532366","issue_url":"https://api.github.com/repos/dart-lang/mockito/issues/47","id":269532366,"user":{"login":"srawlins","id":103167,"avatar_url":"https://avatars.githubusercontent.com/u/103167?v=3","gravatar_id":"","url":"https://api.github.com/users/srawlins","html_url":"https://github.com/srawlins","followers_url":"https://api.github.com/users/srawlins/followers","following_url":"https://api.github.com/users/srawlins/following{/other_user}","gists_url":"https://api.github.com/users/srawlins/gists{/gist_id}","starred_url":"https://api.github.com/users/srawlins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/srawlins/subscriptions","organizations_url":"https://api.github.com/users/srawlins/orgs","repos_url":"https://api.github.com/users/srawlins/repos","events_url":"https://api.github.com/users/srawlins/events{/privacy}","received_events_url":"https://api.github.com/users/srawlins/received_events","type":"User","site_admin":false},"created_at":"2016-12-28T20:01:34Z","updated_at":"2016-12-28T20:01:34Z","body":"Debugging something today, I could really use this feature :stuck_out_tongue_closed_eyes: "}}
{"actor":{"display_login":"srawlins"}}