h1mesuke / vim-unittest Goto Github PK
View Code? Open in Web Editor NEWUnit Testing Framework for Vim script
Unit Testing Framework for Vim script
Consider this dummy plugin myplugin.vim:
let s:var = {}
function! s:get_SID()
return matchstr(expand('<sfile>'), '<SNR>\d\+_')
endfunction
let s:SID = s:get_SID()
delfunction s:get_SID
function! myplugin#__context__()
return { 'sid': s:SID, 'scope': s: }
endfunction
and a test suite for it (test_myplugin.vim):
let s:tc = unittest#testcase#new('MyPluginTests', myplugin#__context__())
function! s:tc.SETUP()
let s:sample = {}
let s:sample['a'] = 'a'
call self.set('s:var', s:sample)
endfunction
function! s:tc.test_one()
call self.assert_equal('a', self.get('s:var')['a'])
endfunction
function! s:tc.test_two()
call self.assert_equal('a', self.get('s:var')['a'])
endfunction
The first test case passes, however, the second - fails.
Vim(call):E716: Key not present in Dictionary: a
And it looks strange, since no modification has been done in the first test case. AFAIU the performed steps are like this:
Aparently, at step 4 the internal dictionary has been reset for some reason.
$ bin/vunit tset_foo.vim
シェルスクリプトでいいだろう。
主に自分用に(おいw
テスト中の「カレント」バッファである context.dataファイルにおいて、ファイル中の特定のマーキングにもとづき、
その行へ移動したり、範囲の選択を行ったりする一連の関数が欲しい。
alignta のテストでやっているので、それをこちらに持ってこれれば。
テストを書いてると欲しくなる機能。
空のテストを "pending" とカウントすることは可能
setup と teadown でオプションやらグローバル変数やらを個別に指定して保存/復元をするのがめんどい。
alignta で使ってる Vimenv を持ってこよう。
branch master
commit 9277877
gvim v8.2
, v9.0
I tried to launch a dummy test case loaded in the current buffer using :UnitTest
and it failed internally (no test launched).
v0.5.1
, everything works successfully
Started at Wed 18 Oct 2023 05:15:42 PM CEST
------------------------------------------------------------------------------
Results
Errors:
1) test_something.vim:
Error: function unittest#run[8]..<SNR>87_TestRunner_load_testcases[5]..script ~/temp/test_something.vim[1]..~/.vim/plugged/vim-unittest/autoload/unittest/testcase.vim[70]..function unittest#assertions#module, line 1
Vim(return):E121: Undefined variable: s:Assertions
1 tests, 0 assertions, 0 failures, 1 errors
Finished in 0.130652 seconds.
let s:tc = unittest#testcase#new("TestCase")
function! s:tc.test_one()
call self.assert(1)
endfunction
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.