vim-gtest


Ⅰ. 插件描述

Vim plugin to quickly select and run GoogleTest asyncronously.

Ⅱ. 基本信息

创建日期:  2015-12-15
使用用户:  20
Github星:  36
插件作者:  Alessandro Pezzato

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'alepez/vim-gtest-all-too-well'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

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

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'alepez/vim-gtest-all-too-well'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'alepez/vim-gtest-all-too-well'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/alepez/vim-gtest

Ⅳ. 文档说明

# vim-gtest

**Vim plugin to quickly select and run
GoogleTest asyncronously.**

asciicast

Usage

Select gtest command

:GTestCmd path/to/test/executable

Or add this line to your .vimrc:

let g:gtest#gtest_command = "path/to/test/executable"

Default is: ./test

Select tests by name

You can select test case and test name, with autocompletion.

:GTestCase MyTestCase
:GTestName MyTestName

Run selected tests

:GTestRun

Find tests

Go to the prev/next test in the current buffer.

:GTestPrev
:GTestNext

Enable/Disable tests under cursor

This remove/add DISABLED_ prefix to test name.

:GTestToggleEnabled

Insert a new test

This insert a new test under cursor.

:GTestNewTest

This text will be inserted, with cursor placed on ✎:

TEST_F(PreviousFixture, ✎) {
}

PreviousFixture is the name of the first fixture found backward in the source

  1. A fixture is something like this:
struct MyTest : public testing::Test {
  ...
}

Run test under cursor

:GTestRunUnderCursor

CtrlP

Don't you know what ctrlp.vim is?

It's a fantastic fuzzy finder for vim! Try it immediately!

vim-gtest extends ctrlp.vim with a google test finder. Now you can find
and launch tests at the speed of light!

Attention: ctrlp.vim must be installed.

QuickFix

You can tell vim-gtest to highlight failing tests using vim's QuickFix.

:let g:gtest#highlight_failing_tests = 1
:GTestRun
:GTestHighlight

If you have vim-dispatch installed,
calling :GTestHighlight isn't needed.

Switch files

You can switch from implementation to header to test:

:GTestJump

By default, filenames must follow this rule:

  • implementation: src/**/*.cpp
  • header: src/**/*.hpp
  • test: test/**/*_test.cpp

Test file suffix can be customized in vimrc using

let g:gtest#test_filename_suffix = "Test"

GTestJump will then look for test filename

  • test: test/**/*Test.cpp

Shortcuts

You can map these commands to your favorite shortcuts. These are mine:

augroup GTest
    autocmd FileType cpp nnoremap <silent> <leader>tt :GTestRun<CR>
    autocmd FileType cpp nnoremap <silent> <leader>tu :GTestRunUnderCursor<CR>
    autocmd FileType cpp nnoremap          <leader>tc :GTestCase<space>
    autocmd FileType cpp nnoremap          <leader>tn :GTestName<space>
    autocmd FileType cpp nnoremap <silent> <leader>te :GTestToggleEnabled<CR>
    autocmd FileType cpp nnoremap <silent> ]T         :GTestNext<CR>
    autocmd FileType cpp nnoremap <silent> [T         :GTestPrev<CR>
    autocmd FileType cpp nnoremap <silent> <leader>tf :CtrlPGTest<CR>
    autocmd FileType cpp nnoremap <silent> <leader>tj :GTestJump<CR>
    autocmd FileType cpp nnoremap          <leader>ti :GTestNewTest<CR>i
augroup END

Development

Contributing

If you'd like to help, check out the
issues. I'd greatly appreciate
any contribution you make. Beer is also appreciated ☺

If you have a question, a feature request, or a new idea, don't hesitate to
post new issues or pull requests. Collaboration is the most awesome thing in
the open source community!

Testing

To test this plugin you need to test it with a testable project. googletest
can test itself. Testception ☺.

This will download and compile google test and its unit tests:

./test/make_test

Now from vim, just call from command line :GTestCmd ./test/launch.

After editing this plugin, just :source % and try something. Samples unit
tests can be found in test/googletest/googletest/samples directory.

Thanks

Thanks to the creator of https://github.com/ctrlpvim/ctrlp.vim

Thanks to the creator of https://github.com/fisadev/vim-ctrlp-cmdpalette,
which allowed me to learn how to extend CtrlP.

Special thanks to Tim Pope, the author of
vim-dispatch and many other useful
plugins.

Self-Promotion

Like vim-gtest? Follow the repository on
GitHub and vote for it on
vim.org. And if you're
feeling especially charitable, follow Alessandro Pezzato
on Twitter and
GitHub.

If you like the plugin please don't forget to leave a :star: for this project!
This will help me to estimate the plugin popularity and plan further
development.

If you have already starred this repo, thank you!

添加新评论