JUnit Generator template
I am trying to change my template to generate a JUnit4 class. Everything works (including /../test/ to send the classes to the test director), except the individual methods are not being generated. Can someone help?
########################################################################################
##
Available variables:
$entryList.methodList - ArrayList of method names
$entryList.fieldList - ArrayList of class scope field names
$entryList.className - class name
$entryList.packageName - package name
$today - Todays date in MM/dd/yyyy format
##
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
Iteratre through the list and generate testcase for every entry.
#foreach ($entry in $entryList)
#set( $testClass="${entry.className}Test")
##
package $entry.packageName;
import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
/**
${entry.className} Tester.
*
@author Norris Shelton
@since <pre>$today</pre>
@version $Revision$
*/
public class $testClass {
/**
Set-up the test. Open a database connection, create test records or anything else you need to do.
*/
@Before
public void setUp() {
// do something
}
#foreach($method in $entry.methodList)
/**
Perform a test.
*/
@Test
public void test#cap($)() {
//TODO: Test goes here...
// assertNotNull(...);
// assertTrue(...);
}
#end
/**
Tear-down the test.
*/
@After
public void tearDown() throws Exception {
// do something
}
}
#end
请先登录再写评论。
Greetings,
Check to see if the methods in the class under test are annotated. I've discovered that annotations prior to function declarations break unit test generation using JUnitGenerator.
Hope that helps.
-- Morgan