When you need to extract a specific method body use the plugin. Consider the following file: class HelloWorldTest { @Test void "should calculate risk based on epsilon"() { generateStatement(price: 10, quantity: 10, epsilon: 2) calcRisk().should == 108 } @Test void "should calculate risk without quantity"() { generateStatement(price: 10, epsilon: 2) calcRisk().should == 108 } } Specify a method name to extract it from the file. If is specified, signature will be omitted. generateStatement(price: 10, quantity: 10, epsilon: 2) calcRisk().should == 108 include-groovy :include-groovy: HelloWorldTest.groovy {entry: "should calculate risk based on epsilon", bodyOnly: true} bodyOnly
Pass as to extract multiple method bodies generateStatement(price: 10, quantity: 10, epsilon: 2) calcRisk().should == 108 generateStatement(price: 10, quantity: 10, epsilon: 2) calcRisk().should == 108 Pass to have a provided line in between entries as a separator. generateStatement(price: 10, quantity: 10, epsilon: 2) calcRisk().should == 108 generateStatement(price: 10, quantity: 10, epsilon: 2) calcRisk().should == 108 list entry :include-groovy: HelloWorldTest.groovy { title: "api example", entry: ["should calculate risk based on epsilon", "should calculate risk based on epsilon"], bodyOnly: true } entrySeparator: "<separator>" :include-groovy: HelloWorldTest.groovy { title: "api example", entry: ["should calculate risk based on epsilon", "should calculate risk based on epsilon"], entrySeparator: "", bodyOnly: true }
Specify types inside brackets to select an overloaded versions of your methods. Types should appear as they do in the file, i.e., if you use the short version of a type, you need to use the short version inside the plugin. import your.company.com.util.* /* groovy docs on top */ class HelloWorld { void methodName(List<String> a, Map<String, Integer> b) { actionA() } void methodName(List<String> a, Boolean b) { actionB() } void methodName(def a, def b) { actionC() } } Note: Generic types are erased and spaces after commas are optional void methodName(List<String> a, Map<String, Integer> b) { actionA() } Note: type remains and not void methodName(def a, def b) { actionC() } :include-groovy: HelloWorld.groovy {entry: "methodName(List, Map)"} :include-groovy: HelloWorld.groovy {entry: "methodName(def,def)"} def def Object
To extract body use: class HelloWorld { void methodName(List<String> a, Map<String, Integer> b) { actionA() } void methodName(List<String> a, Boolean b) { actionB() } void methodName(def a, def b) { actionC() } } Use to only display only the body of your class. void methodName(List<String> a, Map<String, Integer> b) { actionA() } void methodName(List<String> a, Boolean b) { actionB() } void methodName(def a, def b) { actionC() } import your.company.com.util.* /* groovy docs on top */ class HelloWorld { void methodName(List<String> a, Map<String, Integer> b) { actionA() } void methodName(List<String> a, Boolean b) { actionB() } void methodName(def a, def b) { actionC() } } class :include-groovy: HelloWorld.groovy {entry: "HelloWorld"} bodyOnly :include-groovy: HelloWorld.groovy {entry: "HelloWorld", bodyOnly: true}