I have created a project as per the above package structure and I'm facing an issue on running the test's by the testng.xml file I manually created.
All the test classes reside in their own packages under the API package, and the API package consists of each module of the application as packages where test classes are defined in their respective module packages.
In the attached screenshot im referring only one package to be run from the testng.xml file and when running the file it displays as "No tests were found"
below is a code segment of ApprovalGroupManagementApi.class where the test methods are in with propper TestNG annotations.
package com.api.approval_group_management;
import com.base.Base;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.javafaker.Faker;
import com.payloads.request.classes.CreatedUserList;
import com.payloads.request.classes.StatusList;
import com.payloads.request.payload.SecCreateApprovalLevel;
import io.restassured.RestAssured;
import io.restassured.http.ContentType;
import io.restassured.response.Response;
import org.testng.annotations.Test;
import org.testng.asserts.Assertion;
import org.testng.asserts.SoftAssert;
import java.util.ArrayList;
import java.util.List;
import static com.utils.Constant.SEC_CREATE_APPROVAL_LEVEL_URL;
import static io.restassured.RestAssured.given;
public class ApprovalGroupManagementApi extends Base {
SoftAssert softAssert = new SoftAssert();
Assertion hardAssert = new Assertion();
@Test(priority = 1, alwaysRun = true, enabled = true)
public void secCreateApprovalLevel() {
try {
ObjectMapper objectMapper = new ObjectMapper();
SecCreateApprovalLevel secCreateApprovalLevel = new SecCreateApprovalLevel();
StatusList statusList = new StatusList();
CreatedUserList createdUserList = new CreatedUserList();
List<Object> objects = new ArrayList<>();
secCreateApprovalLevel.setName("" + new Faker().name().firstName());
secCreateApprovalLevel.setApprovalLevelAvailable(true);
secCreateApprovalLevel.setStatusList(statusList);
secCreateApprovalLevel.setCreatedUserList(createdUserList);
secCreateApprovalLevel.setPrivilageList(objects);
String approvalGroup = objectMapper.writeValueAsString(secCreateApprovalLevel);
RestAssured.useRelaxedHTTPSValidation();
Response response = given().spec(resourceApiRequestSpecification).log().all()
.contentType(ContentType.JSON)
.when()
.body(approvalGroup)
.post(SEC_CREATE_APPROVAL_LEVEL_URL);
//response code assertion
hardAssert.assertEquals(response.getStatusCode(), 200);
softAssert.assertAll();
} catch (Exception e) {
System.out.println(e);
}
}
}
Aucun commentaire:
Enregistrer un commentaire