【Junit】アノテーションを用いたテストサンプル
package viewda;
import static org.junit.Assert.*;
import org.junit.experimental.theories.DataPoint;
import org.junit.experimental.theories.Theories;
import org.junit.experimental.theories.Theory;
import org.junit.runner.RunWith;
@RunWith(Theories.class)
public class testProIns {
@DataPoint
//1,2,3..param 4...return
public static Fixture INT_PARAM_1 = new Fixture("9111", 3, "3000000",0);
@DataPoint
public static Fixture INT_PARAM_2 = new Fixture("9111", 3, "3000000",1);
static class Fixture {
String x;
int y;
String z;
int a;
Fixture(String x, int y, String z,int a) {
this.x = x;
this.y = y;
this.z = z;
this.a = a;
}
}
@Theory
public void testInsProducts(Fixture params) throws Exception {
insProducts objP = new insProducts();
//expect - actual
assertEquals(params.a,objP.insProducts(params.x,params.y,params.z));
}
}
関連jar
Google Code Archive - Long-term storage for Google Code Project Hosting.
参考にしました。
https://www.oracle.com/webfolder/technetwork/jp/javamagazine/Java-SO15-JUnit-caliskan.pdf