Title: Java fuzzer can't create any values for types with no public constructor (e.g. `LocalDateTime`) · Issue #2437 · UnitTestBot/UTBotJava · GitHub
Open Graph Title: Java fuzzer can't create any values for types with no public constructor (e.g. `LocalDateTime`) · Issue #2437 · UnitTestBot/UTBotJava
X Title: Java fuzzer can't create any values for types with no public constructor (e.g. `LocalDateTime`) · Issue #2437 · UnitTestBot/UTBotJava
Description: Description When creating instances of arbitrary classes Java fuzzer only considers their accessible constructors. However, some classes (e.g. LocalDateTime) only have private constructors while their instances are meant to be created us...
Open Graph Description: Description When creating instances of arbitrary classes Java fuzzer only considers their accessible constructors. However, some classes (e.g. LocalDateTime) only have private constructors while th...
X Description: Description When creating instances of arbitrary classes Java fuzzer only considers their accessible constructors. However, some classes (e.g. LocalDateTime) only have private constructors while th...
Opengraph URL: https://github.com/UnitTestBot/UTBotJava/issues/2437
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Java fuzzer can't create any values for types with no public constructor (e.g. `LocalDateTime`)","articleBody":"**Description**\r\n\r\nWhen creating instances of arbitrary classes Java fuzzer only considers their accessible constructors. However, some classes (e.g. `LocalDateTime`) only have private constructors while their instances are meant to be created using `static` methods.\r\n\r\n**Real world (concrete) example**\r\n\r\nSame as in #2428 \r\n\r\n**To Reproduce**\r\n\r\nRun the following unit test.\r\n```kotlin\r\n@Test\r\nfun `fuzzer can create instances of classes without public constructors but with static factory method in their class`() {\r\n var seenLocalDateTime = false\r\n runBlockingWithContext {\r\n runJavaFuzzing(\r\n TestIdentityPreservingIdGenerator,\r\n methodUnderTest = LocalDateTime::getMinute.javaMethod!!.executableId,\r\n constants = emptyList(),\r\n names = emptyList(),\r\n ) { thisInstance, _, _ -\u003e\r\n val control = runCatching {\r\n ValueConstructor()\r\n .construct(listOfNotNull(thisInstance?.model))\r\n .singleOrNull()?.value\r\n }.getOrNull()?.let { constructedThisInstance -\u003e\r\n assertInstanceOf(LocalDateTime::class.java, constructedThisInstance)\r\n seenLocalDateTime = true\r\n Control.STOP\r\n } ?: Control.CONTINUE\r\n BaseFeedback(Trie.emptyNode(), control)\r\n }\r\n }\r\n assertTrue(seenLocalDateTime) { \"No value was generated for type LocalDateTime\" }\r\n}\r\n```\r\n\r\n**Expected behavior**\r\n\r\nTest passes.\r\n\r\n**Actual behavior**\r\n\r\nTest fails.\r\n\r\n**Visual proofs (screenshots, logs, images)**\r\n\r\n~~~\r\nNo value was generated for type LocalDateTime ==\u003e expected: \u003ctrue\u003e but was: \u003cfalse\u003e\r\n~~~","author":{"url":"https://github.com/IlyaMuravjov","@type":"Person","name":"IlyaMuravjov"},"datePublished":"2023-07-24T08:17:13.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/2437/UTBotJava/issues/2437"}
| 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:7d372573-14cd-a472-fb35-c7e82a5c04b2 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CA4C:11E5DC:2EE9B0:3F6F8F:698D8834 |
| html-safe-nonce | b654797c6a84f38a009c2d41ac8b222c8188b451134b7b9214c04ee2089352b0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQTRDOjExRTVEQzoyRUU5QjA6M0Y2RjhGOjY5OEQ4ODM0IiwidmlzaXRvcl9pZCI6IjU2NDk4OTY5NDA0ODY4NjYxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 46c21de505c294ad27f8dcb12a24f200e32109e80823ef957e3b9506fbb1df47 |
| hovercard-subject-tag | issue:1817890359 |
| 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/2437/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7d737a6ceb6f5d41e39c0c9e448b118e5fffd6ff5ef4509524c81132e3f42a10/UnitTestBot/UTBotJava/issues/2437 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7d737a6ceb6f5d41e39c0c9e448b118e5fffd6ff5ef4509524c81132e3f42a10/UnitTestBot/UTBotJava/issues/2437 |
| og:image:alt | Description When creating instances of arbitrary classes Java fuzzer only considers their accessible constructors. However, some classes (e.g. LocalDateTime) only have private constructors while th... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | IlyaMuravjov |
| 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 | 4c8f4bd0b67d7f1472d0ab3f49827eaae062a36b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width