Skip to content

Python and JS support #1197 #1199

New issue

Have a question about this project? No Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “No Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? No Sign in to your account

Merged
merged 112 commits into from
Nov 9, 2022
Merged

Conversation

tamarinvs19
Copy link
Collaborator

Description

We added Python and JavaScript tests generation.

UI

To expand UtBot UI functionality we added next new modules:

  • utbot-ui-common module:

    • in this module we used no language-specific IntelliJ SDK API
    • this gradle module contains common to all languages logic form utbot-intellij to avoid cyclic dependencies in project building
    • LanguageAssistant access to dynamically connect API from language dependent modules. Now exists Python, JS and JVM assistants.
    • BaseTestModel - parent class for PythonTestModel, JsTestModel and GenerateTestModel. This class was created because GenerateTestModel use JVM specific functions
  • utbot-intellij-python, utbot-intellij-js modules:
    These modules contain language-specific implementations of LanguageAssistans, BaseTestModel, DialogWindow and other classes.

Code generation

Previous solution of the problem with different logic for different languages (Java and Kotlin) in code generation which used CodegenLanguage should not be used with new languages.

Our solution suggest to use abstract class CgLanguageAssistant which contains information about code generation language (e.g. languageKeywords, getters for CgNameGenerator, CgMethodConstructor...). In language-specific modules we can create implementations with language-specific logic.

We did not delete CodegenLanguage.JAVA and CodegenLanguage.Kotln, but it is possible if our solution will be approved.
Base implementation for Java and Kotlin we have already added in org.utbot.framework.plugin.api.

Analogically we added LanguageTestFrameworkManager to organize test framework logic for different languages.

CLI

Modules utbot-cli-python and utbot-cli-js contain command line generation and run tests interface for Python and JavaScript. They depends on utbot-cli module.

Main language modules:

Modules utbot-python and utbot-js can be used from IntelliJ-plugin and from CLI. They contain independent of PSI logic, for example, language UtModels, fuzzing and code generation declarated there.

Fixes #1197

Type of Change

Please delete options that are not relevant.

  • Refactoring (typos and non-functional changes)
  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Automated Testing

We have code examples for testing how UtBot works:

  • utbot-python/samples/
    There are script generate_test_samples.sh for automatic run generation test from cli and run_test_samples.sh for run generated tests.
  • utbot-js/samples/

Manual Scenario

  • Open Python-, JavaScript-project in IDEA and run UtBot plugin.
  • Or, generate and run test with CLI.

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

tamarinvs19 and others added 9 commits October 31, 2022 15:07
# Conflicts:
#	utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/constructor/tree/CgMethodConstructor.kt
#	utbot-intellij/build.gradle.kts
#	utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/actions/GenerateTestsAction.kt
rudolf101 and others added 11 commits November 1, 2022 16:31
# Conflicts:
#	utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/CodeGenerator.kt
#	utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/constructor/tree/CgTestClassConstructor.kt
#	utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/visitor/CgAbstractRenderer.kt
# Conflicts:
#	utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/constructor/tree/CgTestClassConstructor.kt
#	utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/visitor/CgAbstractRenderer.kt
#	utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/generator/CodeGenerationController.kt
…R' into tamarinvs19/UnitTestBot_Family_PR

# Conflicts:
#	utbot-js/src/main/kotlin/service/BasicCoverageService.kt
# Conflicts:
#	utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/ui/components/TestFolderComboWithBrowseButton.kt
@tamarinvs19 tamarinvs19 merged commit ef83e13 into main Nov 9, 2022
@tamarinvs19 tamarinvs19 deleted the tamarinvs19/UnitTestBot_Family_PR branch November 9, 2022 07:36
CaelmBleidd added a commit that referenced this pull request Nov 10, 2022
No Sign up for free to join this conversation on GitHub. Already have an account? No Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Python and JS support
9 participants