Created
November 12, 2013 05:39
-
-
Save dylanninin/7426041 to your computer and use it in GitHub Desktop.
A Jinja2 template for rendering source code of jUnit testcase in Java web applications, especially for interfaces. It just shows the basic design, you can impletement it better with Python or Java, either is good.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package {{tc.toPackage}}; | |
{% for import in tc.imports %} | |
import {{import}};{% endfor %} | |
/** | |
* {{tc.testCase}}.java | |
* {{tc.comment.abstract}}: | |
* TestCase (JUnit) for {{tc.service}} | |
* {{tc.comment.history}} | |
* {{tc.comment.date}} {{tc.comment.author}} {{tc.comment.content}} | |
*/ | |
public class {{tc.testCase}} extends {{tc.superTestCase}} {{'{'}} | |
private {{tc.service}} {{tc.serviceInstance}} = ({{tc.service}}) ctx.getBean("{{tc.serviceBean}}"); | |
{% for test in tc.tests %} | |
/** | |
* test method {{test.method}} | |
*/ | |
public void {{test.test}}() {{test.throw}} {{'{'}} | |
//JUnit Add your test implementation here | |
{% for param in test.params %}{{param.type}} {{param.name}} = {{param.value}}; | |
{% endfor %} | |
{#{{test.returnType}} {{test.returnInstance}} {{test.assign}} {{tc.serviceInstance}}.{{test.method}}({{test.paramsInit}});#} | |
{{test.call}} | |
{% for assert in test.asserts %}{{assert}} | |
{% endfor %} | |
{{'}'}} | |
{% endfor %} | |
{{'}'}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment