Skip to content

Update UnitTestBot Python, JavaScript, Go docs #1989

New issue

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

By clicking “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? Sign in to your account

Merged
merged 4 commits into from
Mar 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 19 additions & 18 deletions utbot-go/README.md → docs/GoSupport.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ so feel free to [contribute](https://github.com/UnitTestBot/UTBotJava/blob/main/
## Features and details

UnitTestBot Go now implements the _basic fuzzing technique_.
It generates input values with respect to parameter types,
It generates input values considering the parameter types,
inserts these values into the user functions, and executes the resulting test cases.

### Supported types for function parameters

At the moment, UnitTestBot Go is able to generate values for _primitive types_, _arrays_, _slices_ and _structs_.
Now UnitTestBot Go can generate values for _primitive types_, _arrays_, _slices_ and _structs_.

For _floating point types_, UnitTestBot Go supports working with _infinity_ and _NaN_.

### Supported types for the returned results

For the returned function results,
UnitTestBot Go supports the `error` type in addition to all the types supported for the function parameters.
UnitTestBot Go supports the `error` type as well as all the types supported for the function parameters.

It also captures `panic` cases correctly.

Expand Down Expand Up @@ -58,44 +58,45 @@ use the `go mod tidy` command. For editing and formatting `go.mod` files, use th
In the future, we plan to make UnitTestBot Go working with arbitrary code as input and generate the simplest
Go projects automatically.

## Installation and usage
## IntelliJ IDEA plugin

### IntelliJ IDEA plugin
### Requirements

#### Requirements

* IntelliJ IDEA (Ultimate Edition) — versions from 2022.2 to 2022.2.4
* IntelliJ IDEA Ultimate — for compatibility, see [UnitTestBot on JetBrains Marketplace](https://plugins.jetbrains.com/plugin/19445-unittestbot/versions).
* Go SDK 1.18 or later
* Compatible [Go plugin](https://plugins.jetbrains.com/plugin/9568-go) for IntelliJ IDEA
* Properly configured `go.mod` file for the code under test
* `github.com/stretchr/testify/assert` Go module installed (IntelliJ IDEA automatically offers to install it as soon as the tests are generated)

#### Installation
### Installation

Please refer to [UnitTestBot user guide](https://github.com/UnitTestBot/UTBotJava/wiki/Install-or-update-plugin).

### Usage

To install the UnitTestBot Go plugin in IntelliJ IDEA, refer to [UnitTestBot user guide](https://github.com/UnitTestBot/UTBotJava/wiki/Install-or-update-plugin).
1. In your IntelliJ IDEA, go to **File** > **Settings** > **Tools**, choose **UnitTestBot** and enable **Experimental languages support**.

#### Usage
**(!) NOTE:** be sure to enable this option for **_each_** project.

1. In your IntelliJ IDEA, go to **File** > **Settings** > **Tools** > **UnitTestBot** and enable **Experimental languages support**.
2. Open a `.go` file and press **Alt+Shift+U**.
3. In the **Generate Tests with UnitTestBot** window, you can configure the settings.

### CLI
## Command-line interface (CLI)

#### Requirements
### Requirements

* Java SDK 11 or later
* Go SDK 1.18 or later
* Properly configured `go.mod` file for the code under test
* GCC as well as `github.com/stretchr/testify/assert` and `golang.org/x/tools@v0.4.0` Go modules installed
* GCC and `github.com/stretchr/testify/assert` installed

#### Installation
### Installation

To install the UnitTestBot Go CLI application, go to GitHub, scroll through the release notes and click **Assets**.
Download the zip-archive named like **utbot-cli-VERSION**.
Extract the JAR file from the archive.

#### Usage
### Usage

Run the extracted JAR file using a command line: `generateGo` and `runGo` actions are supported for now.
To find info about the options for these actions,
Expand Down Expand Up @@ -138,4 +139,4 @@ java -jar utbot-cli-2022.8-beta.jar runGo --help
## Contributing to UnitTestBot Go

To take part in project development or learn more about UnitTestBot Go, check
out the [Developer guide](docs/DEVELOPER_GUIDE.md) and our [future plans](docs/FUTURE_PLANS.md).
out the [Developer guide](../utbot-go/docs/DEVELOPER_GUIDE.md) and our [plans](../utbot-go/docs/FUTURE_PLANS.md).
48 changes: 27 additions & 21 deletions docs/JavaScriptSupport.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,44 @@
# UnitTestBot JavaScript plugin setup
# UnitTestBot JavaScript

## How to start using UnitTestBot JavaScript
[UnitTestBot](https://www.utbot.org/) is the tool for automated unit test generation available as an IntelliJ IDEA plugin, or a command-line interface.

1. [Install](https://www.jetbrains.com/idea/download/) the latest version of IntelliJ IDEA Ultimate.
2. [Install](https://plugins.jetbrains.com/plugin/19445-unittestbot) the latest version of UnitTestBot plugin.
3. [Install](https://nodejs.org/en/download/) Node.js 10.0.0 or later. Add Node.js to environment variables for better experience.
4. In your IntelliJ IDEA, go to **File** > **Settings** > **Tools** > **UnitTestBot** and enable **Experimental languages support**.
5. Go to **File** > **Settings** > **Languages & Frameworks**, choose **Node.js** and check if the path to Node.js executable file is specified.
6. In a JavaScript file, press **Alt+Shift+U** to open the generation dialog.
Now UnitTestBot provides fuzzing-based support for JavaScript.

## Troubleshooting: _npm_ cannot install requirements
## IntelliJ IDEA plugin

1. The system prohibits installation
### Requirements

Solution: run _cmd_ via `sudo` or with administrator access, run `npm install -g <missing requirement>`.
1. IntelliJ IDEA Ultimate — for compatibility, see [UnitTestBot on JetBrains Marketplace](https://plugins.jetbrains.com/plugin/19445-unittestbot/versions).
2. UnitTestBot plugin: please refer to [UnitTestBot user guide](https://github.com/UnitTestBot/UTBotJava/wiki/Install-or-update-plugin).
3. [Node.js 10.0.0 or later](https://nodejs.org/en/download/) (we recommend that you add Node.js to environment variables)

_Note:_ when _npm_ cannot install requirements, try troubleshooting.
1. If the system prohibits installation: run _cmd_ via `sudo` or with administrator access, run `npm install -g <missing requirement>`.
2. If Node.js is missing, or _npm_ is not installed: install Node.js with default configuration from the official website.

2. Node.js is missing, or _npm_ is not installed
### How to use

Solution: install Node.js with default configuration from the official website.
1. In your IntelliJ IDEA, go to **File** > **Settings** > **Tools**, choose **UnitTestBot** and enable **Experimental languages support**.

**(!) NOTE:** be sure to enable this option for **_each_** project.

# JavaScript Command Line Interface usage
2. Go to **File** > **Settings** > **Languages & Frameworks**, choose **Node.js** and check if the path to Node.js executable file is specified.
3. In a JavaScript file, press **Alt+Shift+U** to open the generation dialog.

## Build
## Command-line interface (CLI)

### Build

JAR file can be built in [GitHub Actions](https://github.com/UnitTestBot/UTBotJava/actions/workflows/publish-plugin-and-cli-from-branch.yml) with the `publish-plugin-and-cli-from-branch` script.

## Requirements
### Requirements

* [Install](https://nodejs.org/en/download/) Node.js 10.0.0 or later
* [Install](https://www.oracle.com/java/technologies/downloads/) Java 11 or later
* Install _nyc_ 15.1.0 or later: `> npm install -g nyc`
* Install Mocha 10.0.0 or later: `> npm install -g mocha`
* [Node.js 10.0.0 or later](https://nodejs.org/en/download/)
* [Java 11 or later](https://www.oracle.com/java/technologies/downloads/)
* _nyc_ 15.1.0 or later: `> npm install -g nyc`
* Mocha 10.0.0 or later: `> npm install -g mocha`

## Basic usage
_Note:_ for each new project, _npm_ needs internet connection to install the required packages.

### Generate tests: `generate_js`

Expand Down
31 changes: 31 additions & 0 deletions docs/PythonSupport.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# UnitTestBot Python

[UnitTestBot](https://www.utbot.org/) is the tool for automated unit test generation available as an IntelliJ IDEA plugin, or a command-line interface.

Now UnitTestBot provides fuzzing-based support for Python.

## Requirements

1. IntelliJ IDEA — for compatibility, see [UnitTestBot on JetBrains Marketplace](https://plugins.jetbrains.com/plugin/19445-unittestbot/versions).
2. Python 3.8 or later
3. [Python plugin](https://plugins.jetbrains.com/plugin/631-python) for IntelliJ IDEA

If you already have a Python project, you usually have no need to install or configure anything else, but if you
have trouble with launching UnitTestBot for Python code, please refer to [advanced requirements section](../utbot-python/docs/CLI.md#requirements).

## How to install and use

To try UnitTestBot Python in your IntelliJ IDEA:
1. To install the plugin, please refer to [UnitTestBot user guide](https://github.com/UnitTestBot/UTBotJava/wiki/Install-or-update-plugin).
2. Configure the Python interpreter for your project and make sure IntelliJ IDEA resolves all the imports.
3. In your IntelliJ IDEA, go to **File** > **Settings** > **Tools**, choose **UnitTestBot** and enable **Experimental languages support**.

**(!) NOTE:** be sure to enable this option for **_each_** project.

4. To generate tests, place the caret at the required function and press **Alt+Shift+U**. To find the appropriate shortcut for the OS you are using, check the context menu.

To use UnitTestBot Python via command-line interface, please refer to the [CLI guide](../utbot-python/docs/CLI.md).

## How to contribute and get support

To get information on contributing and getting support, please see [UnitTestBot Java Readme](https://github.com/UnitTestBot/UTBotJava#readme).
48 changes: 0 additions & 48 deletions utbot-python/README.md

This file was deleted.