{"action":"created","issue":{"url":"https://api.github.com/repos/mockk/mockk/issues/101","repository_url":"https://api.github.com/repos/mockk/mockk","labels_url":"https://api.github.com/repos/mockk/mockk/issues/101/labels{/name}","comments_url":"https://api.github.com/repos/mockk/mockk/issues/101/comments","events_url":"https://api.github.com/repos/mockk/mockk/issues/101/events","html_url":"https://github.com/mockk/mockk/issues/101","id":335851625,"node_id":"MDU6SXNzdWUzMzU4NTE2MjU=","number":101,"title":"Testing code using data class copy() with mocks","user":{"login":"rrva","id":887132,"node_id":"MDQ6VXNlcjg4NzEzMg==","avatar_url":"https://avatars0.githubusercontent.com/u/887132?v=4","gravatar_id":"","url":"https://api.github.com/users/rrva","html_url":"https://github.com/rrva","followers_url":"https://api.github.com/users/rrva/followers","following_url":"https://api.github.com/users/rrva/following{/other_user}","gists_url":"https://api.github.com/users/rrva/gists{/gist_id}","starred_url":"https://api.github.com/users/rrva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rrva/subscriptions","organizations_url":"https://api.github.com/users/rrva/orgs","repos_url":"https://api.github.com/users/rrva/repos","events_url":"https://api.github.com/users/rrva/events{/privacy}","received_events_url":"https://api.github.com/users/rrva/received_events","type":"User","site_admin":false},"labels":[{"id":723011121,"node_id":"MDU6TGFiZWw3MjMwMTExMjE=","url":"https://api.github.com/repos/mockk/mockk/labels/help%20wanted","name":"help wanted","color":"33aa3f","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-06-26T14:37:55Z","updated_at":"2018-06-30T15:42:40Z","closed_at":"2018-06-30T15:42:40Z","author_association":"NONE","body":"If I want to test code which use data classes, and the code under test invokes `copy()`, how can I use mockk? \r\n\r\nThe following test case does not work. But also, as a deeper question, are mocks even suitable for code that modifies the input using copy() ?\r\n\r\n```kotlin\r\npackage foo\r\n\r\nimport io.mockk.every\r\nimport io.mockk.mockk\r\nimport org.junit.Test\r\n\r\nclass MockkDataclassCopyTest {\r\n\r\n    data class Foo(\r\n        val bar: String,\r\n        val baz: String\r\n    )\r\n\r\n    class UnderTest {\r\n\r\n        fun doSomething(f: Foo): Foo {\r\n            return f.copy(baz = \"aaa\")\r\n        }\r\n    }\r\n\r\n    @Test\r\n    fun `testing code which uses data classes and copy() function should work with mocks`() {\r\n        val mockFoo = mockk<Foo>()\r\n        every { mockFoo.bar } returns \"\"\r\n        UnderTest().doSomething(mockFoo)\r\n    }\r\n\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/mockk/mockk/issues/comments/401548611","html_url":"https://github.com/mockk/mockk/issues/101#issuecomment-401548611","issue_url":"https://api.github.com/repos/mockk/mockk/issues/101","id":401548611,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMTU0ODYxMQ==","user":{"login":"oleksiyp","id":5249932,"node_id":"MDQ6VXNlcjUyNDk5MzI=","avatar_url":"https://avatars2.githubusercontent.com/u/5249932?v=4","gravatar_id":"","url":"https://api.github.com/users/oleksiyp","html_url":"https://github.com/oleksiyp","followers_url":"https://api.github.com/users/oleksiyp/followers","following_url":"https://api.github.com/users/oleksiyp/following{/other_user}","gists_url":"https://api.github.com/users/oleksiyp/gists{/gist_id}","starred_url":"https://api.github.com/users/oleksiyp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oleksiyp/subscriptions","organizations_url":"https://api.github.com/users/oleksiyp/orgs","repos_url":"https://api.github.com/users/oleksiyp/repos","events_url":"https://api.github.com/users/oleksiyp/events{/privacy}","received_events_url":"https://api.github.com/users/oleksiyp/received_events","type":"User","site_admin":false},"created_at":"2018-06-30T15:42:40Z","updated_at":"2018-06-30T15:42:40Z","author_association":"COLLABORATOR","body":"Seems question is answered and no further help needed. Closing"}}
{"actor":{"display_login":"oleksiyp"}}