I have to write test cases which contains repetive code.
- The name of the method should be the ClassName delimitted with _ ex: class_name_test
- The object name should be classNameObj and the mock method should take ClassName.class
- The genericObj.call statement is common for all methods The sayHello should be bound to classNameObj and the remaining result is common
- The commonMethods is common for all objects
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();
}