Title: Add support for top-level Kotlin functions #847 by volivan239 · Pull Request #1147 · UnitTestBot/UTBotJava · GitHub
Open Graph Title: Add support for top-level Kotlin functions #847 by volivan239 · Pull Request #1147 · UnitTestBot/UTBotJava
X Title: Add support for top-level Kotlin functions #847 by volivan239 · Pull Request #1147 · UnitTestBot/UTBotJava
Description: Description With these changes, UtBot is able to generate tests for top-level Kotlin functions including extension functions. There are two main subjects that were changed: In plugin, we have to look for KtFiles and their FacadeClasses among the other classes that we were already looking for. Note that as Kotlin reflection is not fully supported for such classes (see issue), some pieces of code were rewritten to use Java reflection. In Kotlin renderer, we should omit calling to classes like MainKt when rendering top-level function calls. In order to support this, method ClassId.isKotlinFile was added, which checks kind in Kotlin's @Metadata annotation (see docs for more info). Also, for extension functions we should replace fictive caller with extension receiver, borrowing it from arguments (see comment to CgMethodCall.takeCallerFromArgumentsIfNeeded() for more detials). Alongside with above changes in plugin and codegen, following side-changes were made to handle exploited problems: Fixed inconsistency between KClass<*>.signature() and MemberInfo.signature() Fixed name in builtin-classids timeunitClassId and durationClassId KCallable<*>.declaringClazz and MemberInfo.paramNames were slightly changed to work properly when given function is an extension function Fixes #847 Type of Change Please delete options that are not relevant. New feature (non-breaking change which adds functionality) How Has This Been Tested? Automated Testing Added tests to org/utbot/examples/codegen/FileWithTopLevelFunctionsTest.kt Manual Scenario Checked on some top-level methods (including fun main() in main class) -- generates correct tests both in Java and Kotlin Checklist (remove irrelevant options): The change followed the style guidelines of the UTBot project Self-review of the code is passed The change contains enough commentaries, particularly in hard-to-understand areas New documentation is provided or existed one is altered No new warnings New tests have been added All tests pass locally with my changes
Open Graph Description: Description With these changes, UtBot is able to generate tests for top-level Kotlin functions including extension functions. There are two main subjects that were changed: In plugin, we have to l...
X Description: Description With these changes, UtBot is able to generate tests for top-level Kotlin functions including extension functions. There are two main subjects that were changed: In plugin, we have to l...
Opengraph URL: https://github.com/UnitTestBot/UTBotJava/pull/1147
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/checks(.:format) |
| route-controller | pull_requests |
| route-action | checks |
| fetch-nonce | v2:ad2d2b97-88ae-940d-68f7-c820602708aa |
| current-catalog-service-hash | 87dc3bc62d9b466312751bfd5f889726f4f1337bdff4e8be7da7c93d6c00a25a |
| request-id | D6D4:1A80DA:71468E:952EEC:698EBEC8 |
| html-safe-nonce | f7931cb1815704308685ebb13db662044b88aaee0821780f05c22e42bb29c98b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENkQ0OjFBODBEQTo3MTQ2OEU6OTUyRUVDOjY5OEVCRUM4IiwidmlzaXRvcl9pZCI6IjY0NTY5ODc2MjMzNjE1Mjc0OTYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | d3c39ba840c18b8350ea078d0a4ef86dc40373336dd4c93a0823e49a47e085d3 |
| hovercard-subject-tag | pull_request:1084808810 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,checks,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/UnitTestBot/UTBotJava/pull/1147/checks |
| twitter:image | https://avatars.githubusercontent.com/u/65076429?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/65076429?s=400&v=4 |
| og:image:alt | Description With these changes, UtBot is able to generate tests for top-level Kotlin functions including extension functions. There are two main subjects that were changed: In plugin, we have to l... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | cb2828a801ee6b7be618f3ac76fbf55def35bbc30f053a9c41bf90210b8b72ba |
| 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 full-width full-width-p-0 |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | e6b91a7e6e46287d26887e3fb7a4161657bab8f7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width