Forum Discussion
hi,
We wrote the following groovy script using the TestRunListener.afterrun event, but this script works rest abi whether the test automation is successful or not. What can I do to make it work only when it fails.
import java.io.BufferedReader
import java.io.InputStreamReader
import java.net.HttpURLConnection
import java.net.URL
def restApiUrl = "URL"
def url = new URL(restApiUrl)
def connection = url.openConnection() as HttpURLConnection
connection.requestMethod = "GET"
if (connection.responseCode == HttpURLConnection.HTTP_OK) {
def response = new StringBuffer()
def reader = new BufferedReader(new InputStreamReader(connection.inputStream))
String line
while ((line = reader.readLine()) != null) {
response.append(line)
}
reader.close()
println("REST API Yanıtı: " + response.toString())
} else {
println("REST API çağrısı başarısız: " + connection.responseCode + ", " + connection.responseMessage)
}connection.disconnect()
Related Content
- 7 years ago
- 7 years ago
Recent Discussions
- 19 hours ago
- 17 days ago