I have to write test cases which contains repetive code.
Instead of copy pasting and changing the ClassName and classNameObj, I am interested in automating this using Vim. Is is possible to do this to which if I pass the Class name, the rest should be generated?
The method template is mentioned below.
@Test
public void stop_video_request_valid_data() throws Throwable {
ClassName classNameObj = mock(ClassName.class);
when(genericObj.call()).thenReturn(new Object[]{classNameObj});
when(classNameObj.sayHello()).thenReturn("Hello");
commonMethods();
}
snippets are like the built-in :abbreviate
on steroids, usually with parameter insertions, mirroring, and multiple stops inside them. One of the first, very famous (and still widely used) Vim plugins is snipMate (inspired by the TextMate editor); unfortunately, it's not maintained any more; though there is a fork. A modern alternative (that requires Python though) is UltiSnips. There are more, see this list on the Vim Tips Wiki.
There are three things to evaluate: First, the features of the snippet engine itself, second, the quality and breadth of snippets provided by the author or others; third, how easy it is to add new snippets.