Title: Asserts are missing for anonymous class · Issue #1034 · UnitTestBot/UTBotJava · GitHub
Open Graph Title: Asserts are missing for anonymous class · Issue #1034 · UnitTestBot/UTBotJava
X Title: Asserts are missing for anonymous class · Issue #1034 · UnitTestBot/UTBotJava
Description: Description If a method returns an anonymous class, the generated test method contains actual and expected, but doesn't assert them to be equal. To Reproduce Run a project in IntelliJ Idea 2022.1.4 with one of the latest plugin builds fr...
Open Graph Description: Description If a method returns an anonymous class, the generated test method contains actual and expected, but doesn't assert them to be equal. To Reproduce Run a project in IntelliJ Idea 2022.1.4...
X Description: Description If a method returns an anonymous class, the generated test method contains actual and expected, but doesn't assert them to be equal. To Reproduce Run a project in IntelliJ Idea 2022...
Opengraph URL: https://github.com/UnitTestBot/UTBotJava/issues/1034
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Asserts are missing for anonymous class","articleBody":"**Description**\r\n\r\nIf a method returns an anonymous class, the generated test method contains actual and expected, but doesn't assert them to be equal.\r\n\r\n**To Reproduce**\r\n\r\n1. Run a project in IntelliJ Idea 2022.1.4 with one of the latest plugin builds from main branch \r\n2. Add the following code:\r\n\r\n```java\r\npublic class A {\r\n\r\n public interface Driver {\r\n public int getNumber(int n);\r\n }\r\n\r\n public Driver getDriver() {\r\n return new Driver() {\r\n @Override\r\n public int getNumber(int n) {\r\n return 2 * n - 1 ;\r\n }\r\n };\r\n }\r\n}\r\n\r\n```\r\n3. Use plugin to generate tests for getDriver() method.\r\n4. Open the generated test\r\n\r\n**Expected behavior**\r\n\r\nTest is supposed to contain assert of expected and actual value.\r\n\r\n**Actual behavior**\r\n\r\nTest contains actual and expected fields, but there is no assertion.\r\n\r\n**Visual proofs (screenshots, logs, images)**\r\n\r\n~~~java\r\nimport org.junit.jupiter.api.Test;\r\nimport org.junit.jupiter.api.DisplayName;\r\n\r\nimport static org.utbot.runtime.utils.UtUtils.createInstance;\r\nimport static org.utbot.runtime.utils.UtUtils.setField;\r\n\r\npublic class ATest {\r\n ///region Test suites for executable A.getDriver\r\n\r\n ///region FUZZER: SUCCESSFUL EXECUTIONS for method getDriver()\r\n\r\n @Test\r\n @DisplayName(\"getDriver: arg_0 = A()\")\r\n public void testGetDriver() throws Exception {\r\n A a = new A();\r\n\r\n A.Driver actual = a.getDriver();\r\n\r\n A.Driver expected = ((A.Driver) createInstance(\"A$1\"));\r\n setField(expected, \"A$1\", \"this$0\", a);\r\n }\r\n ///endregion\r\n\r\n ///endregion\r\n}\r\n~~~\r\n\r\n**Environment**\r\n\r\nWindows 10 Pro\r\nJDK 8\r\n\r\n**Additional context**\r\n\r\nThe same issue can be seen for generating tests for the following code: \r\n\r\n```java\r\npublic class A {\r\n\r\n public int a, b = 10;\r\n\r\n public List\u003cInteger\u003e integerStream (int c) {\r\n return Arrays.asList(a, b, c);\r\n }\r\n}\r\n```","author":{"url":"https://github.com/alisevych","@type":"Person","name":"alisevych"},"datePublished":"2022-09-29T13:36:27.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/1034/UTBotJava/issues/1034"}
| 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:a6f04d15-7c66-8f2a-083e-46d5d3bede99 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8482:DDFC1:79120:9E43D:69904755 |
| html-safe-nonce | a337d6100d328a78dde2c546ddc73e1d5cb8f40b64410407befb9d534954d576 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NDgyOkRERkMxOjc5MTIwOjlFNDNEOjY5OTA0NzU1IiwidmlzaXRvcl9pZCI6Ijg3OTAwNDQzNTcxMTE1OTY4ODUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 2ad8e37c6e1db9a9c8abc985b82c47f6c46accb7427e33c52ba14127cfc13bf1 |
| hovercard-subject-tag | issue:1390889792 |
| 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/1034/issue_layout |
| twitter:image | https://opengraph.githubassets.com/957624124c65ca0acd24a29cc8cae1b938c36487aea19675fb3315808f01e0bc/UnitTestBot/UTBotJava/issues/1034 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/957624124c65ca0acd24a29cc8cae1b938c36487aea19675fb3315808f01e0bc/UnitTestBot/UTBotJava/issues/1034 |
| og:image:alt | Description If a method returns an anonymous class, the generated test method contains actual and expected, but doesn't assert them to be equal. To Reproduce Run a project in IntelliJ Idea 2022.1.4... |
| 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 | 42c603b9d642c4a9065a51770f75e5e27132fef0e858607f5c9cb7e422831a7b |
| 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 | 3b33c5aedc9808f45bc5fcf0b1e4404cf749dac7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width