{"action":"created","issue":{"url":"https://api.github.com/repos/mockk/mockk/issues/177","repository_url":"https://api.github.com/repos/mockk/mockk","labels_url":"https://api.github.com/repos/mockk/mockk/issues/177/labels{/name}","comments_url":"https://api.github.com/repos/mockk/mockk/issues/177/comments","events_url":"https://api.github.com/repos/mockk/mockk/issues/177/events","html_url":"https://github.com/mockk/mockk/issues/177","id":382100452,"node_id":"MDU6SXNzdWUzODIxMDA0NTI=","number":177,"title":"Verification faile. Method was not called","user":{"login":"LipatovNikita","id":22917776,"node_id":"MDQ6VXNlcjIyOTE3Nzc2","avatar_url":"https://avatars0.githubusercontent.com/u/22917776?v=4","gravatar_id":"","url":"https://api.github.com/users/LipatovNikita","html_url":"https://github.com/LipatovNikita","followers_url":"https://api.github.com/users/LipatovNikita/followers","following_url":"https://api.github.com/users/LipatovNikita/following{/other_user}","gists_url":"https://api.github.com/users/LipatovNikita/gists{/gist_id}","starred_url":"https://api.github.com/users/LipatovNikita/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LipatovNikita/subscriptions","organizations_url":"https://api.github.com/users/LipatovNikita/orgs","repos_url":"https://api.github.com/users/LipatovNikita/repos","events_url":"https://api.github.com/users/LipatovNikita/events{/privacy}","received_events_url":"https://api.github.com/users/LipatovNikita/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-11-19T08:14:32Z","updated_at":"2018-11-19T08:30:37Z","closed_at":null,"author_association":"NONE","body":"I have a simple Spring MVC app with three layers - dao, service and controller. \r\nFor example, I have `ObjectService`\r\n```\r\npublic interface ObjectService {\r\n    Object getById(Object object);\r\n}\r\n```\r\nand its implementation\r\n```\r\n@Service\r\npublic class ObjectServiceImpl implements ObjectService {\r\n   private final ObjectDao objectDao;\r\n   \r\n   @Autowired\r\n   public ObjectServiceImpl(ObjectDao objectDao) {\r\n      this.objectDao = objectDao;\r\n   }\r\n\r\n   @Override\r\n   @Transactional(readOnly = true)\r\n   public Object getById(Object object) {\r\n      return objectDao.getById(object.getId());\r\n   }\r\n}\r\n```\r\nI decided to add unit testing using Kotlin and found MockK. But using this library I get exceptions(\r\nHere is an example of my test class:\r\n```\r\n@ContextConfiguration(locations = [\"classpath:spring/app-context-test.xml\"])\r\nclass ObjectServiceTests : StringSpec() {\r\n   private val objectDao = mockk<ObjectDao>()\r\n   private lateinit var objectServiceImpl: ObjectServiceImpl\r\n   \r\n   override fun beforeTest(description: Description) {\r\n       super.beforeTest(description)\r\n       objectServiceImpl = ObjectServiceImpl(objectDao)\r\n   }\r\n\r\n   init {\r\n        \"simpleTest\" {\r\n            every { objectDao.getById(any()) } returns null\r\n            objectServiceImpl.getById(object())\r\n            verify { objectDao.getById(any()) }\r\n        }\r\n    }\r\n}\r\n```\r\nAnd execption... `java.lang.AssertionError: Verification failed: call 1 of 1: ObjectDao(#1).getById(any())) was not called`\r\n\r\nHelp to understand, please\r\n\r\n#### Context\r\n\r\n* MockK version: 1.8.13.kotlin13\r\n* Kotlin version: 1.3.0\r\n* JDK version: 1.8\r\n* JUnit version: kotlintest-runner-junit5 (3.1.8)"},"comment":{"url":"https://api.github.com/repos/mockk/mockk/issues/comments/439810032","html_url":"https://github.com/mockk/mockk/issues/177#issuecomment-439810032","issue_url":"https://api.github.com/repos/mockk/mockk/issues/177","id":439810032,"node_id":"MDEyOklzc3VlQ29tbWVudDQzOTgxMDAzMg==","user":{"login":"LipatovNikita","id":22917776,"node_id":"MDQ6VXNlcjIyOTE3Nzc2","avatar_url":"https://avatars0.githubusercontent.com/u/22917776?v=4","gravatar_id":"","url":"https://api.github.com/users/LipatovNikita","html_url":"https://github.com/LipatovNikita","followers_url":"https://api.github.com/users/LipatovNikita/followers","following_url":"https://api.github.com/users/LipatovNikita/following{/other_user}","gists_url":"https://api.github.com/users/LipatovNikita/gists{/gist_id}","starred_url":"https://api.github.com/users/LipatovNikita/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LipatovNikita/subscriptions","organizations_url":"https://api.github.com/users/LipatovNikita/orgs","repos_url":"https://api.github.com/users/LipatovNikita/repos","events_url":"https://api.github.com/users/LipatovNikita/events{/privacy}","received_events_url":"https://api.github.com/users/LipatovNikita/received_events","type":"User","site_admin":false},"created_at":"2018-11-19T08:30:37Z","updated_at":"2018-11-19T08:30:37Z","author_association":"NONE","body":"That is, it will be enough to add a bytebuddy dependency?"}}
{"actor":{"display_login":"LipatovNikita"}}