|
20 | 20 | let s:JavaUnit_TestMethod_Source =
|
21 | 21 | \g:JavaUnit_Home
|
22 | 22 | \.s:Fsep
|
23 |
| - \.join(['src','com','wsdjeg','util','TestMethod.java'],s:Fsep) |
| 23 | + \.join(['src' , 'com' , 'wsdjeg' , 'util' , '*.java'],s:Fsep) |
24 | 24 |
|
25 | 25 | function! javaunit#Compile() abort
|
26 | 26 | silent exec '!javac -encoding utf8 -d "'.s:JavaUnit_tempdir.'" "'.s:JavaUnit_TestMethod_Source .'"'
|
@@ -176,5 +176,34 @@ function! javaunit#TestMain(...) abort
|
176 | 176 | endif
|
177 | 177 | call javaunit#util#ExecCMD(cmd)
|
178 | 178 | endfunction
|
| 179 | + |
| 180 | +fu! javaunit#GenerateTestMethods() |
| 181 | + let testClassName = expand('%:t:r') |
| 182 | + if stridx(testClassName, 'test') != -1 || stridx(testClassName, 'Test') != -1 |
| 183 | + let line = getline(search("package","nb",getline("0$"))) |
| 184 | + let testClassName = split(split(line," ")[1],";")[0]."." . testClassName |
| 185 | + if stridx(testClassName, 'Test') == len(testClassName) - 4 |
| 186 | + let className = strpart(testClassName, 0,len(testClassName) - 4) |
| 187 | + echomsg testClassName |
| 188 | + echomsg className |
| 189 | + let cmd="java -cp '" |
| 190 | + \.s:JavaUnit_tempdir |
| 191 | + \.s:Psep |
| 192 | + \.getcwd() |
| 193 | + \.join(['','target','test-classes'],s:Fsep) |
| 194 | + \.s:Psep |
| 195 | + \.get(g:,'JavaComplete_LibsPath','.') |
| 196 | + \."' com.wsdjeg.util.GenerateMethod " |
| 197 | + \.className |
| 198 | + echomsg system(cmd) |
| 199 | + else |
| 200 | + echohl WarningMsg | echomsg "This is not a testClassName,now only support className end with 'Test'" | echohl None |
| 201 | + endif |
| 202 | + else |
| 203 | + echohl WarningMsg | echomsg "This is not a testClassName" | echohl None |
| 204 | + endif |
| 205 | +endf |
| 206 | + |
| 207 | + |
179 | 208 | let &cpo = s:save_cpo
|
180 | 209 | unlet s:save_cpo
|
0 commit comments