小编The*_*tor的帖子

TestNG - 软断言

我有一个@Test脚本设置,它运行一些soft asserts.

但是,我遇到了assertAll. 我希望URLsassertAll. 这是可能的还是另一种推荐的方法?

@Test
public static void checkUrl(String requestUrl, String expectedUrl){

    SoftAssert softAssert = new SoftAssert ();

    try {

        URL obj = new URL(requestUrl);
        HttpURLConnection conn = (HttpURLConnection) obj.openConnection();
        conn.setReadTimeout(5000);
        conn.addRequestProperty("Accept-Language", "en-US,en;q=0.8");
        conn.addRequestProperty("User-Agent", "Mozilla");
        conn.addRequestProperty("Referer", "google.com");
        System.out.println();
        System.out.println("Request URL ... " + requestUrl);


        boolean redirect = false;

        // normally, 3xx is redirect
        int status = conn.getResponseCode();
        if (status != HttpURLConnection.HTTP_OK) {
            if (status == HttpURLConnection.HTTP_MOVED_TEMP
                    || status == …
Run Code Online (Sandbox Code Playgroud)

java testng

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

java ×1

testng ×1