引入maven依賴
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
創建測試用例(建議以方法爲單位編寫單元測試用例)
Demo.java
public class Demo {
public String method() {
return "This is a demo method.";
}
}
DemoTest.java