--Until now, UnitTest has been executed by vim-quickrun or after returning with C-Z and hitting the terminal. --Currently, it's hard to do test-driven development with Vim. ――It's time to create test settings. --By the way, it's Python's Unit Test
:QuickRun
--QuickRun can only run the entire test. I think (because I'm not a test runner)
――It may be possible if you do your best.
――It's hard to do the whole execution many times for a long test or a slow test. I want to do just one method or something quickly.QuickFix
. Seeing terminal errors-> Vim back-> Returning to terminal error seeing is stupid.:make
--Make can do anything for the time being. (I confirmed that I could do it roughly, but I did not say that I could do it)
――The setting seems to be difficult. Do you write settings for builtin unittest, djangotest, nose, pytest, etc. It's hard.Make Vim's test environment feel good. In particular...
--What you can do on Vim --Test class / method unit execution is possible --You can output the result to QuickFix and jump ――It can be handled to some extent even if the number of target languages / frameworks increases. --You can specify test execution options (if this is not possible, you will eventually return to make) --Asynchronous execution
For the time being. Check through the test plugins. Type test
in the search form of Vim Awesome.
Then I realize that there are surprisingly few solutions with existing plugins. There weren't many test plugins themselves ... Is there a lot of people solving it with make?
vim-test A plugin called vim-test came out at the top. Besides, pytest.vim and [vim-python-test-runner](https://github.com/jarrodctaylor/vim-python-test- There were runners), but in the end only vim-test met the requirements.
Although it is a rough investigation, measures are started for the time being
Insco vim-test. My interpretation is that English is inconvenient
--Test wrapper for various particle sizes --Supports various languages and frameworks --No dependent plugins for test execution only --You don't have to set that much ――You can choose the runner to run. It will be detected automatically without explicitly selecting it. --You can also specify CLI options
It was a plug-in that was easy to install and had a lot of customization. I remember ALE.
Put it in for the time being. Dakpawa dein.vim. By the way, I manage all plugins in toml.
[[plugins]]
repo = 'janko-m/vim-test'
There are 5 types of test execution methods as follows. For more information here
Make a test and run it. Execute : TestFile
I was able to execute it. But QuickFix isn't, and you can't scroll, so you can't follow the entire error message. This is meaningless.
Read the vim-test README. Apparently, if you want to output to QuickFix, you need another plugin as a test runner. Therefore, the author recommends Dispatch.vim.
When I looked it up, it was a plug-in that was pretty cool. In short, it's a plugin for asynchronous execution of the compiler, but it splits the execution process into screens and displays it. Moreover, it is a kind specification that automatically detects the execution environment and divides the screen without permission. In my case it's tmux & neovim. I created a tmux pane without permission, closed it when I finished, and put out QuickFix.
Dein.vim again. Also, explicitly set Dispatch.vim as a runner on the vim-test side.
[[plugins]]
repo = 'tpope/vim-dispatch'
[[plugins]]
repo = 'janko-m/vim-test'
depends = ['vim-dispatch']
hook_add = '''
let g:test#strategy = 'dispatch'
'''
Execute Mokkai : TestFile
.
QuickFix is displayed safely. However, errorformat was not applied to QuickFix. You can't jump with this.
For the time being, the error format of Python has been set as follows, but it seems that this is useless.
augroup MyErrorFormat
autocmd!
autocmd BufNewFile,BufRead *.py
\ setlocal errorformat=%A\ \ File\ \"%f\"\\,\ line\ %l%.%#,%Z%[%^\ ]%\\@=%m
augroup END
Looking at the help of Dispatch.vim, it seems that errorformat will have the default applied if there is no compiler plugin to run.
:Dispatch[!] [options] {program} [arguments]
Find a compiler plugin that sets 'makeprg' to
{program} and use its 'errorformat' to dispatch a
|:Make| for the given {program} and [arguments]. If
no compiler plugin is found, the generic format
%+I%.%# is used.
I wondered what it was and looked it up, and found a plug-in that looked like it.
vim-compiler-python seems to be a plug-in that looks at the source and manages the compiler settings at the time of : make
. I don't think it's really good, but I'm exhausted so I'll check it later.
Dein.vim again.
[[plugins]]
repo = 'aliev/vim-compiler-python'
Execute Mokkai : TestFile
.
I finally reached the level I was looking for. vimrc I haven't messed with it, but I'm tired.
The setting added this time looks like this. To be honest, I still have test option settings and key binding settings, but I'll do that again next time.
[[plugins]]
repo = 'tpope/vim-dispatch'
[[plugins]]
repo = 'janko-m/vim-test'
depends = ['vim-dispatch']
hook_add = '''
let g:test#strategy = 'dispatch'
'''
[[plugins]]
repo = 'aliev/vim-compiler-python'
Recommended Posts