5

Github GitHub - rcarriga/vim-ultest: The ultimate testing plugin for (Neo)Vim

 3 years ago
source link: https://github.com/rcarriga/vim-ultest
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

vim-ultest

This plugin is in the early stages of development so there will likely be bugs! If you experience any problems please open an issue with as much detail as possible i.e. error messages, file type, test runner and minimal example.

Introduction

The ultimate testing plugin for NeoVim

Running tests should be as quick and painless as possible. vim-test is a very powerful and extensive testing plugin, but it can be cumbersome to configure and lacks some features to make it feel like an integrated piece of your editor.

Rather than replacing vim-test altogether, vim-ultest (in name and practice) builds upon vim-test to make it even better while maintaining the ability to use your existing configuration. If you're already using vim-test then switching to vim-ultest is as easy as installing and... well, that's pretty much it.

The goal behind vim-ultest is to make running tests as seamless as possible.

Features

  • Run tests and view results individually
    • Test result markers using signs or virtual text
    • Failure outputs in a floating window
    • Key mappings to jump between failed tests
    • Stop long running tests
  • Attach to running processes to debug
    • Currently experimental so please report issues!
    • Uses python's readline library to pass input
  • Summary window
    • Highlight tests based on current status (running, succeeded, failed)
    • Show test output
    • View all tests currently found in all test files
    • Run tests with key binding
  • Multithreaded (not just asynchronous) to prevent blocking

  • Use existing vim-test configuration

  • Customisable

More features are being worked on. If you have any ideas, feel free to open an issue!

Installation

Requirements:

All users:

Vim only:

Note: Vim support is maintained with a best effort. Due to the differences between Vim and NeoVim and their RPC libraries, it is inevitable that bugs will occur in one and not the other. I primarily use NeoVim so I will catch issues in it myself. Please file bug reports for Vim if you find them!

I have not had the chance to extensively test (Neo)Vim versions, it is recommended to stay on the latest nightly version. If you have issues with missing features, please open an issue with your editor version.

vim-ultest can be installed as usual with your favourite plugin manager. Note: NeoVim users must run :UpdateRemotePlugins after install if they don't use a plugin manager that already does.

dein:

" Vim Only
call dein#add("roxma/nvim-yarp")
call dein#add("roxma/vim-hug-neovim-rpc")

call dein#add("janko/vim-test")
call dein#add("rcarriga/vim-ultest")

vim-plug

" Vim Only
Plug "roxma/nvim-yarp"
Plug "roxma/vim-hug-neovim-rpc"

Plug "janko/vim-test"
Plug "rcarriga/vim-ultest", { "do": ":UpdateRemotePlugins" }

packer.nvim

use { "rcarriga/vim-ultest", requires = {"janko/vim-test"}, run = ":UpdateRemotePlugins" } }

Usage

Configuration

:help ultest-config

Any vim-test configuration should carry over to vim-ultest. See the vim-test documentation on further details for changing test runner and options. If you have compatibility problems please raise an issue.

One change you will notice is that test output is not coloured. This is due to the way the command is run. To work around this you can simply tell your test runner to always output with colour. For example

let test#python#pytest#options = "--color=yes"

let test#javascript#jest#options = "--color=always"

Note: The window to show results relies on the 'updatetime' setting which by default is 4 seconds. A longer 'updatetime' will mean the window takes longer to show automatically but a shorter time means (Neo)Vim will write to disk much more often which can degrade SSDs over time and cause slowdowns on HDDs.

Commands

:help ultest-commands

For example to run the nearest test every time a file is written:

augroup UltestRunner
    au!
    au BufWritePost * UltestNearest
augroup END

Plug mappings

:help ultest-mappings

For example to be able to jump between failures in a test file:

nmap ]t <Plug>(ultest-next-fail)
nmap [t <Plug>(ultest-prev-fail)

For configuration options and more documentation see :h ultest

Debugging

:help ultest-debugging

Debugging with nvim-dap is supported but some user configuration is required. See the debugging recipes for some working configurations. If you do not see one for your runner/language, please submit a change to the wiki so others can use it too!

Feedback

Feel free to open an issue for bug reports, feature requests or suggestions. I will try address them as soon as I can!


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK