Compile TestingJava 測試工具
Compile Testing 是一個用來測試 Java 和注釋處理器的工具。
示例代碼:
@RunWith(JUnit4.class)
public class TreeContextTest {
@Rule public final ExpectedException expectedExn = ExpectedException.none();
private static final String LITERAL_VALUE = "literal";
private static final ImmutableList<String> baseTreeSource = ImmutableList.of(
"package test;",
"",
"final class TestClass {",
" public String toString() {",
" Object variable = new Object();",
" return \"" + LITERAL_VALUE + "\" + variable;",
" }",
"",
" public void nonsense() {",
" int[] numbers = {0, 1, 2, 3, 4};",
" for (int x : numbers) {",
" if (x % 2 == 0) {",
" throw new IllegalStateException();",
" }",
" }",
" }",
"}");評論
圖片
表情
