-
Notifications
You must be signed in to change notification settings - Fork 2
/
junit_gen_template.txt
81 lines (71 loc) · 2.56 KB
/
junit_gen_template.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
OUTPUT PATH:
${SOURCEPATH}/${PACKAGE}/test/${FILENAME}
------------------ PASTE FROM HERE
########################################################################################
##
## Available variables:
## $entryList.methodList - List of method composites
## $entryList.privateMethodList - List of private method composites
## $entryList.fieldList - ArrayList of class scope field names
## $entryList.className - class name
## $entryList.packageName - package name
## $today - Todays date in MM/dd/yyyy format
##
## MethodComposite variables:
## $method.name - Method Name
## $method.signature - Full method signature in String form
## $method.reflectionCode - list of strings representing commented out reflection code to access method (Private Methods)
## $method.paramNames - List of Strings representing the method's parameters' names
## $method.paramClasses - List of Strings representing the method's parameters' classes
##
## You can configure the output class name using "testClass" variable below.
## Here are some examples:
## Test${entry.ClassName} - will produce TestSomeClass
## ${entry.className}Test - will produce SomeClassTest
##
########################################################################################
##
#macro (cap $strIn)$strIn.valueOf($strIn.charAt(0)).toUpperCase()$strIn.substring(1)#end
## Iterate through the list and generate testcase for every entry.
#foreach ($entry in $entryList)
#set( $testClass="${entry.className}Test")
##
package ${entry.packageName}.test;
import java.util.Scanner;
import java.io.PrintWriter;
import org.junit.Test;
import org.junit.Before;
import org.junit.After;
import static org.junit.Assert.*;
import ${entry.packageName}.*;
/**
* ${entry.className} Tester.
*
* @author <Premkumar Bhaskal>
* @since <pre>$date</pre>
* @version 1.0
*/
public class $testClass {
${entry.className} testClass = new ${entry.className}();
long starttime;
@Before
public void before() throws Exception {
starttime = System.nanoTime();
}
@After
public void after() throws Exception {
long now = System.nanoTime();
System.out.println("elapsed time " + (now-starttime)/1000000 + "milli secs");
}
#foreach($method in $entry.methodList)
/**
*
* Method: $method.signature
*
*/
@Test
public void test#cap(${method.name})() throws Exception {
}
#end
}
#end