vim-quickrun-hook-unittest


Ⅰ. 插件描述

Quickrun hook for enable to unittest by selecting method.

Ⅱ. 基本信息

创建日期:  2012-06-16
使用用户:  2
Github星:  12
插件作者:  Shinya Ohyanagi

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'heavenshell/vim-quickrun-hook-unittest'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'heavenshell/vim-quickrun-hook-unittest'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'heavenshell/vim-quickrun-hook-unittest'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/heavenshell/vim-quickrun-hook-unittest

Ⅳ. 文档说明

# Quickrun hook for unittest

QuickRun hook for enable to unittest by selecting method.

For example.

from unittest import TestCase

class TestFoo(TestCase):
    def test_foo(self):
        pass

    def test_bar(TestCase):
        pass

QuickRun execute all tests.
But if you want to run only test_bar() method.

Python

Python

Jest

Jest

Install

Install the distributed files into Vim runtime directory which is usually
~/.vim/, or $HOME/vimfiles on Windows.

If you install pathogen that provided from Tim Pope, you should extract the
file into 'bundle' directory.

Usage

  1. Add below example to your .vimrc or _vimrc.
nnoremap <silent> ,r :QuickRun -mode n -runner job -hook/unittest/enable 1<CR>
  1. Open your unittest file.
  2. Move cursor to test method scope.
  3. For example, move cursor next to def test_foo(self) line.
  4. Type ,r and then execute QuickRun automatically.
  5. QuickRun output only test_foo() test result.

Test runners

This plugin required awesome testing framework/runner to run.

Example QuickRun configs

augroup QuickRunUnitTest
  autocmd!
  autocmd BufWinEnter,BufNewFile *test.php setlocal filetype=php.unit
  " Choose UnitTest, py.test or Django.
  autocmd BufWinEnter,BufNewFile test_*.py setlocal filetype=python.unit
  "autocmd BufWinEnter,BufNewFile test_*.py setlocal filetype=python.pytest
  "autocmd BufWinEnter,BufNewFile test_*.py setlocal filetype=python.django
  autocmd BufWinEnter,BufNewFile *.t       setlocal filetype=perl.unit
  autocmd BufWinEnter,BufNewFile *_spec.rb setlocal filetype=ruby.rspec
  autocmd BufWinEnter,BufNewFile *_test.rb setlocal filetype=ruby.minitest
  autocmd BufWinEnter,BufNewFile *_test.go setlocal filetype=go.test
  " TypeScript support only Jest
  autocmd BufWinEnter,BufNewFile *.spec.ts setlocal filetype=typescript.jest
  " Choose Mocha or Jest
  "autocmd BufWinEnter,BufNewFile *.test.js setlocal filetype=javascript.mocha
  "autocmd BufWinEnter,BufNewFile *.test.js setlocal filetype=javascript.jest
augroup END
let g:quickrun_config = {}
let g:quickrun_config['php.unit']         = { 'command': 'testrunner', 'cmdopt': 'phpunit' }
let g:quickrun_config['python.unit']      = { 'command': 'nosetests',  'cmdopt': '-v -s'   }
let g:quickrun_config['python.pytest']    = { 'command': 'py.test',    'cmdopt': '-v'      }
" Django unittest
let g:quickrun_config['python.django']    = { 'command': 'python',     'cmdopt: 'test --pararell=2 --keepdb -v2'}
" pytest-django
" let g:quickrun_config['python.django']    = { 'command': 'python',   'cmdopt: 'test --noinput -- --verbose --reuse-db', 'test_fw': 'pytest' }
let g:quickrun_config['ruby.rspec']       = { 'command': 'rspec',      'cmdopt': '-f d'    }
let g:quickrun_config['ruby.minitest']    = { 'command': 'ruby'                            }
let g:quickrun_config['go.test']          = { 'command': 'go',         'cmdopt': 'test -v' }
let g:quickrun_config['javascript.mocha'] = { 'command': 'mocha' }
let g:quickrun_config['javascript.mocha'] = { 'command': 'jest' }

LICENSE

zlib License(Same as vim-quickrun)

添加新评论