{"action":"created","issue":{"url":"https://api.github.com/repos/jmockit/jmockit1/issues/529","repository_url":"https://api.github.com/repos/jmockit/jmockit1","labels_url":"https://api.github.com/repos/jmockit/jmockit1/issues/529/labels{/name}","comments_url":"https://api.github.com/repos/jmockit/jmockit1/issues/529/comments","events_url":"https://api.github.com/repos/jmockit/jmockit1/issues/529/events","html_url":"https://github.com/jmockit/jmockit1/issues/529","id":338585388,"node_id":"MDU6SXNzdWUzMzg1ODUzODg=","number":529,"title":"Using subclass of Expectations fails","user":{"login":"rhuss","id":99080,"node_id":"MDQ6VXNlcjk5MDgw","avatar_url":"https://avatars3.githubusercontent.com/u/99080?v=4","gravatar_id":"","url":"https://api.github.com/users/rhuss","html_url":"https://github.com/rhuss","followers_url":"https://api.github.com/users/rhuss/followers","following_url":"https://api.github.com/users/rhuss/following{/other_user}","gists_url":"https://api.github.com/users/rhuss/gists{/gist_id}","starred_url":"https://api.github.com/users/rhuss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rhuss/subscriptions","organizations_url":"https://api.github.com/users/rhuss/orgs","repos_url":"https://api.github.com/users/rhuss/repos","events_url":"https://api.github.com/users/rhuss/events{/privacy}","received_events_url":"https://api.github.com/users/rhuss/received_events","type":"User","site_admin":false},"labels":[{"id":112393989,"node_id":"MDU6TGFiZWwxMTIzOTM5ODk=","url":"https://api.github.com/repos/jmockit/jmockit1/labels/question","name":"question","color":"cc317c","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-07-05T13:55:09Z","updated_at":"2018-07-09T08:35:12Z","closed_at":"2018-07-06T20:15:31Z","author_association":"NONE","body":"Please provide the following information:\r\n\r\n* Version of JMockit that was used: 1.40\r\n\r\n* Description of the problem: \r\n\r\nI'm trying to upgrade my testsuite from 1.33 to 1.40 and have a problem when trying to use subclasses of `Expectations` to encapsulate common behaviour to be reused in various tests.\r\n\r\nExample: \r\n\r\n```java\r\n@Test\r\npublic void test() throws Exception {\r\n   new Expectations() {{\r\n      service.doSomething();\r\n      log.debug(anyString); times = 0;\r\n      new LogInfoMatchingExpectations(container, true);\r\n   }};\r\n}\r\n\r\nfinal class LogInfoMatchingExpectations extends Expectations {\r\n    LogInfoMatchingExpectations(String container, boolean withRemove) {\r\n        log.info(withSubstring(\"Stop\"),\r\n                 anyString,\r\n                 withRemove ? withSubstring(\"removed\") : withNotEqual(\" and removed\"),\r\n                 withSubstring(container.substring(0,12)),\r\n                 anyLong);\r\n    }\r\n}\r\n```\r\n\r\nThis fails with a \r\n\r\n```\r\nMissing 1 invocation to:\r\nio.fabric8.maven.docker.util.Logger#info(a string containing \"Stop\", a string containing \"removed\")\r\n   on mock instance: io.fabric8.maven.docker.util.$Impl_Logger@32e6e9c3\r\ninstead got:\r\nio.fabric8.maven.docker.util.Logger#info(\"%s: Stop%s container %s after %s ms\", [\"[test_name:latest] \\\"testAlias\\\"\", \" and removed\", \"testContaine\", 0L])\r\n\tat io.fabric8.maven.docker.service.RunService.shutdown(RunService.java:455)\r\n```\r\n\r\nHowever, when I inline the Expectations, then it works again:\r\n\r\n```java\r\n@Test\r\npublic void test() throws Exception {\r\n   new Expectations() {{\r\n      service.doSomething();\r\n      log.debug(anyString); times = 0;\r\n      log.info(withSubstring(\"Stop\"),\r\n               anyString,\r\n               withSubstring(\"removed\"),\r\n               withSubstring(container.substring(0,12)),\r\n               anyLong);\r\n   }};\r\n}\r\n```\r\n\r\nIs this a bug or if not, what is the way these days to collect expectations in reusable way ?\r\n"},"comment":{"url":"https://api.github.com/repos/jmockit/jmockit1/issues/comments/403402932","html_url":"https://github.com/jmockit/jmockit1/issues/529#issuecomment-403402932","issue_url":"https://api.github.com/repos/jmockit/jmockit1/issues/529","id":403402932,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMzQwMjkzMg==","user":{"login":"rhuss","id":99080,"node_id":"MDQ6VXNlcjk5MDgw","avatar_url":"https://avatars3.githubusercontent.com/u/99080?v=4","gravatar_id":"","url":"https://api.github.com/users/rhuss","html_url":"https://github.com/rhuss","followers_url":"https://api.github.com/users/rhuss/followers","following_url":"https://api.github.com/users/rhuss/following{/other_user}","gists_url":"https://api.github.com/users/rhuss/gists{/gist_id}","starred_url":"https://api.github.com/users/rhuss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rhuss/subscriptions","organizations_url":"https://api.github.com/users/rhuss/orgs","repos_url":"https://api.github.com/users/rhuss/repos","events_url":"https://api.github.com/users/rhuss/events{/privacy}","received_events_url":"https://api.github.com/users/rhuss/received_events","type":"User","site_admin":false},"created_at":"2018-07-09T08:35:12Z","updated_at":"2018-07-09T08:35:12Z","author_association":"NONE","body":"@rliesenfeld what would be the recommendation these days for creating reusable and parameterized expectations in order to avoid duplicated test code ?"}}
{"actor":{"display_login":"rhuss"}}