Skip to content

Testing

Paul Jolly edited this page Jan 3, 2025 · 12 revisions

For now, we do not have any (meaningful) end-to-end/integration tests. For now therefore we run through the following scenarios offline using VSCode. This list could/should form the basis for the later addition of real automated tests that cover these situations.

For the purposes of these tests, the following scenario "shorthands" are delcared:

  • A valid workspace refers to a VSCode workspace rooted in a directory that defines a CUE module (i.e. contains cue.mod/module.cue).

Happy-path tests

  1. Verify that for a valid workspace the extension sees and responds to runtime configuration changes, and that cue lsp is started/stopped according to the resulting configuration, including updating the version number in the status bar.
  2. In a folder/workspace with zero config, and ensuring that we have no global config set for the extension (i.e. we rely on defaults), open a CUE file to start the LSP (which will rely on cmd/cue in PATH) and ensure that we use cue from PATH, and ensure we see the :zap: icon in the status bar.
  3. Similarly, in a valid workspace where we have a configuration setting for cueCommand as a valid value, ensure that the LSP runs and that we see the :zap: icon in the status bar.
  4. Ensure that in a valid workspace we are able to format a .cue file via the right-click menu.

Sad-path tests

  1. Ensuring that we get an error message when opening a CUE file in untitled workspace mode (see comment 'Extension instances and configuration'). This is easiest achieved by closing any existing workspace/folder, and opening a single .cue file anywhere.
  2. Ensuring that we get an error message when trying to start the LSP via the command, but in a configuration state of useLanguageServer: false.
  3. Ensuring we get an error message when the cmd/cue version used does not support the LSP (as determined by cue help lsp returning an error). e.g. by using v0.10.0.
  4. Ensuring we get an error when the configured cueCommand is a non-simple relative path, e.g. ./cue.
  5. With an absolute cueCommand value that points to a non-existent path, ensure that we get an error shown to the user.
  6. With an empty cueCommand value, ensure we get shown an error message.
Clone this wiki locally