基本單元測試示例
此示例是使用 junit 對 StringBuilder.toString()
進行單元測試的基本設定。
import static org.junit.Assert.assertEquals;
import org.junit.Test;
public class StringBuilderTest {
@Test
public void stringBuilderAppendShouldConcatinate() {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("String");
stringBuilder.append("Builder");
stringBuilder.append("Test");
assertEquals("StringBuilderTest", stringBuilder.toString());
}
}