GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — RETURNS_SELF breaks methods with generic return type · Issue #2686 · mockito/mockito Closed DescriptionI'm trying to use RETURNS_SELF to mock a builder with a generic method: private static class HttpBuilder { private String uri; public HttpBuilder withUri(String uri) { this.uri = uri; return this } ... public <T> T request(T result) { return result; // Do typed request } } It is easy enough to mock using: val builder = mock(HttpBuilder.class, RETURNS_SELF); However this breaks: given(builder.request(anyString())).willAnswer(i → "Mocked result"); The problem is, that Is it possible for mockito to check whether the return type of the method is generic? In that case I would suggest a fix to never return edit: What do you think of checking whether return type is of type edit 2: Added #2687 to demonstrate the issue with a test and solution proposal. Happy to update with any comments Activity
MetadataMetadataAssigneesLabelsNo labels TypeProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |