当我运行我的testNG类时收到错误,因为无法实例化类

时间:2016-02-11 10:30:34

标签: java eclipse rest rest-assured

请有人帮我解决这个问题....

org.testng.TestNGException: 
Cannot instantiate class com.abcd.apitesting.bvt.accBVT
at org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:40)
at org.testng.internal.ClassHelper.createInstance1(ClassHelper.java:377)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
Caused by: java.lang.RuntimeException: Unable to load properties        file:/configure.properties
at com.thed.zeeapitesting.util.Configure.init(Configure.java:26)

在eclipse中运行testNG类时出现错误,如

我的代码就像

import org.testng.annotations.BeforeClass;
import com.jayway.restassured.RestAssured;
import com.jayway.restassured.builder.RequestSpecBuilder;
import com.jayway.restassured.specification.RequestSpecification;
import com.abcd.abcapitesting.action.Factory;

public class Trigger {

    protected static boolean isInit = false;
    protected static IInfoAction inf = null;
    protected static String Version = null;
    protected static String sessionId = null;
    public static boolean initializeInfoAPI = true;

    public Trigger() {
        init();
    }

    public static void init() {
        if (isInit) {
            return;
        }
        Configure configure = new Configure();
        Version = Configure.getValue("VERSION");
        Factory.init(Version);
        if (initializeInfoAPI) {
            inf = Factory.getInfoActionInstance();
        }
        isInit = true;
    }

    @BeforeClass
    public void setup() {
        RestAssured.baseURI = Configure.getValue("abc_BASE_URL");
        RestAssured.port = Integer.parseInt(Configure.getValue("abc_PORT"));
        RestAssured.basePath = Configure.getValue("abc_BASE_PATH");
        sessionId = inf.createSessionId(RestUtil.setRequest()).asString();

    }
}

我的testNG课程如下

public class abcBVT extends Trigger {
    public void Trigger() {
        initializeInfoAPI = true;
    }

    @Test(priority = 1, enabled = enableAll)
    public void bvt1_getManifest() {
        JSONResponseBody = inf.getManifest(RestUtil.setRequest(sessionId));
        status = inf.validateManifest(JSONResponseBody);
        if (status) {
            logger.info("getManifest Executed Successfully...!");
        }
    }
}

我被封锁了。

0 个答案:

没有答案