Title: Other class is not mocked as required · Issue #747 · UnitTestBot/UTBotJava · GitHub
Open Graph Title: Other class is not mocked as required · Issue #747 · UnitTestBot/UTBotJava
X Title: Other class is not mocked as required · Issue #747 · UnitTestBot/UTBotJava
Description: Description When Mocking strategy is set to "Other classes: Mockito" - other classes should be mocked in all tests. To Reproduce Steps to reproduce the behavior: Run IntelliJ IDEA 2022.1.4 with one of the latest builds of UTBot plugin fr...
Open Graph Description: Description When Mocking strategy is set to "Other classes: Mockito" - other classes should be mocked in all tests. To Reproduce Steps to reproduce the behavior: Run IntelliJ IDEA 2022.1.4 with one...
X Description: Description When Mocking strategy is set to "Other classes: Mockito" - other classes should be mocked in all tests. To Reproduce Steps to reproduce the behavior: Run IntelliJ IDEA 2022.1....
Opengraph URL: https://github.com/UnitTestBot/UTBotJava/issues/747
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Other class is not mocked as required","articleBody":"**Description**\r\n\r\nWhen Mocking strategy is set to \"Other classes: Mockito\" - other classes should be mocked in all tests.\r\n\r\n**To Reproduce**\r\n\r\nSteps to reproduce the behavior:\r\n\r\n1. Run IntelliJ IDEA 2022.1.4 with one of the latest builds of UTBot plugin from main branch installed.\r\n2. Open UTBotJava project\r\n3. Find utbot-sample/src/main/java/org/utbot/examples/mock/CommonMocksExample.java\r\n4. Generate tests for nextValue() method with Mocking strategy is set to \"Other classes: Mockito\"\r\n5. Open the generated test\r\n\r\n**Expected behavior**\r\n\r\nRecursiveTypeClass used as the input parameter of the method is supposed to be mocked in all tests - except the one with null used.\r\n\r\n**Actual behavior**\r\n\r\nThere are 4 tests generated. RecursiveTypeClass is mocked only in one test.\r\n\r\n**Visual proofs (screenshots, logs, images)**\r\n\r\n~~~java\r\npublic class CommonMocksExampleTest {\r\n\r\n @Test\r\n public void testNextValue() {\r\n CommonMocksExample commonMocksExample = new CommonMocksExample();\r\n RecursiveTypeClass node = new RecursiveTypeClass();\r\n RecursiveTypeClass recursiveTypeClass = new RecursiveTypeClass();\r\n recursiveTypeClass.next = null;\r\n recursiveTypeClass.value = 0;\r\n node.next = recursiveTypeClass;\r\n node.value = 0;\r\n\r\n RecursiveTypeClass actual = commonMocksExample.nextValue(node);\r\n\r\n RecursiveTypeClass nodeNext = node.next;\r\n RecursiveTypeClass actualNext = actual.next;\r\n RecursiveTypeClass actualNextNext = actualNext.next;\r\n assertNull(actualNextNext);\r\n\r\n int nodeNextValue = nodeNext.value;\r\n int actualNextValue = actualNext.value;\r\n assertEquals(nodeNextValue, actualNextValue);\r\n\r\n int nodeValue = node.value;\r\n int actualValue = actual.value;\r\n assertEquals(nodeValue, actualValue);\r\n }\r\n\r\n @Test\r\n public void testNextValueThrowsNPE() {\r\n CommonMocksExample commonMocksExample = new CommonMocksExample();\r\n RecursiveTypeClass node = new RecursiveTypeClass();\r\n \r\n /* This test fails because method [org.utbot.examples.mock.CommonMocksExample.nextValue] produces [java.lang.NullPointerException]\r\n org.utbot.examples.mock.CommonMocksExample.nextValue(CommonMocksExample.java:25) */\r\n commonMocksExample.nextValue(node);\r\n }\r\n\r\n @Test\r\n public void testNextValue_NodeNextEqualsNode() {\r\n CommonMocksExample commonMocksExample = new CommonMocksExample();\r\n RecursiveTypeClass nodeMock = mock(RecursiveTypeClass.class);\r\n nodeMock.next = nodeMock;\r\n\r\n RecursiveTypeClass actual = commonMocksExample.nextValue(nodeMock);\r\n\r\n int nodeMockValue = nodeMock.value;\r\n int actualValue = actual.value;\r\n assertEquals(nodeMockValue, actualValue);\r\n }\r\n\r\n @Test\r\n public void testNextValue_ThrowNullPointerException() {\r\n CommonMocksExample commonMocksExample = new CommonMocksExample();\r\n \r\n /* This test fails because method [org.utbot.examples.mock.CommonMocksExample.nextValue] produces [java.lang.NullPointerException]\r\n org.utbot.examples.mock.CommonMocksExample.nextValue(CommonMocksExample.java:21) */\r\n commonMocksExample.nextValue(null);\r\n }\r\n\r\n}\r\n~~~\r\n\r\n**Environment**\r\n\r\nWindows 10 Pro\r\nGradle project \r\nJDK 8\r\n\r\n**Additional context**\r\n\r\nWhen generating tests for MockWithFieldExample with same setting : Other classes : Mockito - VersionStamp is not mocked either","author":{"url":"https://github.com/alisevych","@type":"Person","name":"alisevych"},"datePublished":"2022-08-19T14:32:14.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/747/UTBotJava/issues/747"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:46a7dc18-a32f-a3ed-62e1-758cfd743152 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DE46:E2DB2:1C58167:25D9425:698D9394 |
| html-safe-nonce | a19305b23da5ed31c4f6c45b172bd42bfb08dfa260efb4f2b3a9e85127979992 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERTQ2OkUyREIyOjFDNTgxNjc6MjVEOTQyNTo2OThEOTM5NCIsInZpc2l0b3JfaWQiOiI0NDk4Njc5MDgyNjc4ODUwNDUyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | ad43568eee03cef566c4d33e266de467fa3730b66af4352fc5389539eaef546e |
| hovercard-subject-tag | issue:1344525873 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/UnitTestBot/UTBotJava/747/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3778b6f5c628c6c197628a56a208b7847cf4d617a70523a6fc0dd2d04b1d45c9/UnitTestBot/UTBotJava/issues/747 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3778b6f5c628c6c197628a56a208b7847cf4d617a70523a6fc0dd2d04b1d45c9/UnitTestBot/UTBotJava/issues/747 |
| og:image:alt | Description When Mocking strategy is set to "Other classes: Mockito" - other classes should be mocked in all tests. To Reproduce Steps to reproduce the behavior: Run IntelliJ IDEA 2022.1.4 with one... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | alisevych |
| hostname | github.com |
| expected-hostname | github.com |
| None | c0818105fa276287e9369cfdefa0a0fa7953719791ceff9b94d69623c0a4fe8a |
| turbo-cache-control | no-preview |
| go-import | github.com/UnitTestBot/UTBotJava git https://github.com/UnitTestBot/UTBotJava.git |
| octolytics-dimension-user_id | 87413538 |
| octolytics-dimension-user_login | UnitTestBot |
| octolytics-dimension-repository_id | 480810501 |
| octolytics-dimension-repository_nwo | UnitTestBot/UTBotJava |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 480810501 |
| octolytics-dimension-repository_network_root_nwo | UnitTestBot/UTBotJava |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | cefb6b50cb02e85b21d59b711abca4e67e11cf47 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width