I am writing test scripts with Rest-Assured java. I have two classes ApiMethods and AppMethods belonging to one package and another test package called apiTests using the methods created in the ApiMethods and AppMethods classes. I am getting error (Can't invoke public void apiTests.TestCase.caseApi(): either make it static or add a no-args constructor to your class) while running the test class file.
AppMethods class looks like this:
package com.sape.utilMethods;
import com.sape.base.Base;
public class AppMethods extends Base{
private String MethodA(String abc) {
//Some code
//return statement
}
}
ApiMethods class looks like this:
package com.sape.utilMethods;
import com.sape.base.Base;
public class ApiMethods extends Base{
public AppMethods appObj;
public ApiMethods(AppMethods appObj) {
this.appObj = appObj;
}
public String MethodB() {
appObj.MethodA();
}
}
The test case class under apiTests package looks like this:
package apiTests;
import com.sape.base.Base;
import com.sape.utilMethods.ApiMethods;
import com.sape.utilMethods.AppMethods;
import io.restassured.RestAssured;
import static io.restassured.RestAssured.given;
import io.restassured.response.Response;
public class TestCase extends Base {
public AppMethods appObj;
public ApiMethods apiMethods;
public TestClass(AppMethods appObj) {
this.appObj = appObj;
this.apiMethods= new ApiMethods(appObj);
}
@Test
public void caseApi() {
apiMethods.MethodB();
}
}
It seems I am doing something incorrectly in the caseApi method, while creating ApiMethods object. Can someone help me in passing the data correctly? I am bit new to java so sorry if this question is something very basic
TestCase
class. Where is it?