Skip to content

Latest commit

 

History

History
41 lines (28 loc) · 1.11 KB

File metadata and controls

41 lines (28 loc) · 1.11 KB

JUnit4 FreeMarker Test Framework

build status

a test framework for freemarker, you can use this project for learning freemarker step by step.

Test Syntax

<@test name="test some feature">
  <#assign foo="bar">
  
  <@assert expected='bar' actual=foo/>
  <@assert expected=foo=='bar'/>
  <@assert expected=foo>bar</@assert>
</@test>

<@test name="matching test will failed with exception" expected="java.lang.Exception">${invalid_expression}</@test>

Get Started

Write a test make it run as ScriptRunner and defined a method annotated with @Scanner annotation return an instance of ScriptScanner.

@RunWith(ScriptRunner.class)
public class FreeMarkerRunnerExample {

  public static @Scanner ScriptScanner scanner() {
    return new FileSystemScriptScanner(file("src/test/resources"),
        allOf(not(startsWith("_")), endsWith(".ftl")));
  }
}

Test Result

test result