Created
December 1, 2023 15:12
-
-
Save rahulrathore44/5d3c29a128fd45b30197e1cd5a15f8fb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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