Skip to content

Instantly share code, notes, and snippets.

@rahulrathore44
Created December 1, 2023 15:12
Show Gist options
  • Save rahulrathore44/5d3c29a128fd45b30197e1cd5a15f8fb to your computer and use it in GitHub Desktop.
Save rahulrathore44/5d3c29a128fd45b30197e1cd5a15f8fb to your computer and use it in GitHub Desktop.
package com.automation.env;
import io.restassured.RestAssured;
public class QueryRestEndPoint {
public String getData() {
String url = System.getenv("ENV_URL");
return RestAssured.given().get(url).thenReturn().asString();
}
}
package com.automation.env;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junitpioneer.jupiter.RestoreEnvironmentVariables;
import org.junitpioneer.jupiter.SetEnvironmentVariable;
@RestoreEnvironmentVariables
public class TestQueryRestEndPoint {
private QueryRestEndPoint query = new QueryRestEndPoint();
@Test
@SetEnvironmentVariable(key = "ENV_URL", value = "http://demo9511612.mockable.io/info")
public void test_Get_info_end_point() {
String response = query.getData();
Assertions.assertTrue(response.contains("name"), "Name Property not found");
}
@Test
@SetEnvironmentVariable(key = "ENV_URL", value = "http://demo9511612.mockable.io/phone")
public void test_Get_phone_end_point() {
String response = query.getData();
Assertions.assertTrue(response.contains("PhoneNumber"), "PhoneNumber Property not found");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment