Title: Do not set final fields with direct accessors in UtAssembleModel · Issue #14 · UnitTestBot/UTBotJava · GitHub
Open Graph Title: Do not set final fields with direct accessors in UtAssembleModel · Issue #14 · UnitTestBot/UTBotJava
X Title: Do not set final fields with direct accessors in UtAssembleModel · Issue #14 · UnitTestBot/UTBotJava
Description: Suppose we have a class with a public final field whose content can be modified (e.g., an array): public class PublicFinalFieldExample { public final int[] data = {1, 2}; public boolean foo(int x) { return x == data[0]; } } Expected beha...
Open Graph Description: Suppose we have a class with a public final field whose content can be modified (e.g., an array): public class PublicFinalFieldExample { public final int[] data = {1, 2}; public boolean foo(int x) ...
X Description: Suppose we have a class with a public final field whose content can be modified (e.g., an array): public class PublicFinalFieldExample { public final int[] data = {1, 2}; public boolean foo(int x) ...
Opengraph URL: https://github.com/UnitTestBot/UTBotJava/issues/14
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Do not set final fields with direct accessors in UtAssembleModel","articleBody":"Suppose we have a class with a public final field whose content can be modified (e.g., an array):\r\n\r\n```\r\npublic class PublicFinalFieldExample {\r\n public final int[] data = {1, 2};\r\n \r\n public boolean foo(int x) {\r\n return x == data[0];\r\n }\r\n}\r\n```\r\nExpected behavior: \r\nUtAssembleModel is not created, final field is set via reflection.\r\n\r\nActual behavior:\r\nThe generated tests for foo contain the direct assignment to the data field instead of assignment to the array elements or changing the field value using reflection:\r\n\r\n```\r\n@Test\r\n--\r\n@DisplayName(\"foo: return data[0] == x : False -\u003e return data[0] == x\")\r\npublic void testFoo_0OfDataNotEqualsX() throws Throwable {\r\n PublicFinalArrayExample publicFinalArrayExample = new PublicFinalArrayExample();\r\n int[] intArray = new int[1];\r\n intArray[0] = 1;\r\n publicFinalArrayExample.data = intArray; // Error: this line does not compile\r\n \r\n boolean actual = publicFinalArrayExample.foo(-224);\r\n \r\n assertFalse(actual);\r\n}\r\n```\r\n\r\nTesting instructions:\r\nAssembleModelGeneratorTests should be enlarged with one more test for objects with final fields.\r\nOther tests should still pass.","author":{"url":"https://github.com/EgorkaKulikov","@type":"Person","name":"EgorkaKulikov"},"datePublished":"2022-05-24T13:31:45.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/14/UTBotJava/issues/14"}
| 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:f55e7569-d1b5-4f9a-3281-7b428f716e14 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B716:A1BB5:1D5030B:2602D2E:69909F11 |
| html-safe-nonce | 343153e98dac8136594ed44bf90c89ff6a114945aa5bc1b0613c78fb4892500e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNzE2OkExQkI1OjFENTAzMEI6MjYwMkQyRTo2OTkwOUYxMSIsInZpc2l0b3JfaWQiOiI1MzAzNzc1NzU3NDkwNzU3MzkzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 085673c2d3bef11fd53924120bc5eff1b0ead611abe4ac6b9bd9c9e647f3f61c |
| hovercard-subject-tag | issue:1246563007 |
| 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/14/issue_layout |
| twitter:image | https://opengraph.githubassets.com/eb55d335b758d49f26407bd70936b2097cd6f14a6b5043e7a47e25acadc4604a/UnitTestBot/UTBotJava/issues/14 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/eb55d335b758d49f26407bd70936b2097cd6f14a6b5043e7a47e25acadc4604a/UnitTestBot/UTBotJava/issues/14 |
| og:image:alt | Suppose we have a class with a public final field whose content can be modified (e.g., an array): public class PublicFinalFieldExample { public final int[] data = {1, 2}; public boolean foo(int x) ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | EgorkaKulikov |
| 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