我正在尝试制作一个测试运行器,第一个类是测试运行器,第二个是 testet 类,最后一个是我的主页。我想使用方法调用来访问测试器方法,但这不起作用。
public class tester {
public tester()
{
}
@Test
public void testTopla(){
int sayi1 = 10;
int sayi2 = 20;
int gercekSonuc = 30;
//
islem isl = new islem(sayi1, sayi2);
int sonuc = isl.topla();
Assert.assertTrue("Sonucta Hata Var", sonuc == gercekSonuc);
}
and this is what i am testing
public class islem {
private int sayi1;
private int sayi2;
public islem(){
}
public islem(int sayi1, int sayi2){
this.sayi1 = sayi1;
this.sayi2 = sayi2;
}
public int getSayi1() {
return sayi1;
}
public void setSayi1(int sayi1) {
this.sayi1 = sayi1;
}
public int getSayi2() {
return sayi2;
}
public void setSayi2(int sayi2) {
this.sayi2 = sayi2;
}
public int topla(){
return this.sayi1 + this.sayi2;
}
and this
public class Deneme1UI extends UI {
@WebServlet(value = "/*", asyncSupported = true)
@VaadinServletConfiguration(productionMode = false, ui = Deneme1UI.class)
public static class Servlet extends VaadinServlet {
}
@Override
protected void init(VaadinRequest request) {
final VerticalLayout layout = new VerticalLayout();
layout.setMargin(true);
setContent(layout);
Class hilmi = tester.class;
tester obj = new tester();
for(Method method : hilmi.getDeclaredMethods())
{
method.invoke(obj);
}