Skip to content

vscode install and configure

github-actions[bot] edited this page Sep 22, 2023 · 3 revisions

Install and configure the UnitTestBot C/C++ plugin

Install the plugin

Make sure you have already installed the UnitTestBot C/C++ server.

To install the plugin from the VSIX file:

  1. Download a ZIP archive with the release artifact. You can choose the release on GitHub. Unarchive this ZIP file.
  2. In your Visual Studio Code, go to File > Preferences > Extensions and select Views and More Actions.... Select Install from VSIX.

  1. In the folder with the unarchived files from the release artifact, select the utbot_plugin.vsix file and press Install.

Now the UnitTestBot C/C++ plugin is displayed in File > Preferences > Extensions > Installed.

Open the project

Go to File > Open Folder and select the one containing the project to generate tests for.

Configure the plugin using UTBot: Quickstart wizard

To start using UnitTestBot C/C++, follow the wizard:

  • The wizard opens automatically, if you use UnitTestBot C/C++ for your project for the first time.
  • To open the wizard on demand, go to View > Command Palette....

  • Enter Run UTBot: Quickstart Wizard. Click on it.

The UnitTestBot C/C++ server and the client can be installed on the same or on different machines. WSL and Docker also behave differently: WSL automatically forwards the source paths to the server host, while Docker requires establishing an SSH connection. Choose one of two paths in the wizard to start using UnitTestBot C/C++.

On the same machine or via WSL

If the UnitTestBot C/C++ server and the client are installed on the same machine, or the server is installed via WSL (without using Docker), make sure the Default server configuration on localhost (or WSL2) checkbox is selected.

Follow the default procedure — press Next until configuration is complete.

The default settings are:

  • Host: localhost
  • gRPC port: 2121
  • SFTP port: not used
  • Project Path On Server: autofilled
  • Build Directory: build
  • CMake options:
    -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
    -DCMAKE_EXPORT_LINK_COMMANDS=ON

On different machines or via Docker

If the UnitTestBot C/C++ server and the client are installed on different machines, or the server is installed via Docker, you need to sync files within a local directory to a remote server directory using SSH protocol.

Configure an SFTP connection

  1. Install the SFTP plugin for your Visual Studio Code.
  2. Go to View > Command Palette... and enter SFTP: config. Enter your values in sftp.json:
{
   "name": "UTBot Server",
   "host": "127.0.0.1", // IP address of the UnitTestBot server
   "protocol": "sftp",
   "port": 5522,
   "username": "utbot",
   "password": "utbot",
   "remotePath": "/home/utbot/remote/c-example/", // the path to your project on the server host
   "uploadOnSave": true,
   "useTempFile": false,
   "openSsh": false
}
  1. Go to View > Command Palette... and enter SFTP: Sync Local -> Remote. Check SFTP Explorer for the uploaded files.

Perform the initial plugin setup

  1. Go to View > Command Palette... and enter Run UTBot: Quickstart Wizard.

  2. Clear the Default server configuration on localhost (or WSL2) checkbox.

  3. Enter your values in the setting fields — the same as in sftp.json:

    • Host: your host name or IP address
    • gRPC port: 5521
    • SFTP port: 5522
    • Project Path On Server: the path to your project on the server host
    • Build Directory: build
    • CMake options:
      -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
      -DCMAKE_EXPORT_LINK_COMMANDS=ON

Follow the default procedure — press Next until configuration is complete.

The UnitTestBot C/C++ plugin builds and configures the project under test automatically — see notifications.

Clone this wiki locally