CompileTestig是一个用来测试Java和注释处理器的工具。
示例代码:
@RuWith(JUit4.class)public class TreeCotextTest { @Rule public fial ExpectedExceptio expectedEx = ExpectedExceptio.oe(); private static fial Strig LITERAL_VALUE = "literal"; private static fial ImmutableList<Strig> baseTreeSource = ImmutableList.of( "package test;", "", "fial class TestClass {", " public Strig toStrig() {", " Object variable = ew Object();", " retur \"" + LITERAL_VALUE + "\" + variable;", " }", "", " public void osese() {", " it[] umbers = {0, 1, 2, 3, 4};", " for (it x : umbers) {", " if (x % 2 == 0) {", " throw ew IllegalStateExceptio();", " }", " }", " }", "}");
评论