testng多线程运行方式一

数据驱动

 @DataProvider
    public Object[][] getparam() {
        int k = 0;
        String[] param = {"2367952", "2367141", "2366552", "2364334", "2368312"};
        Object[][] result = new Object[param.length][];
        for (int i = 0; i < param.length; i++) {
            MyHttpEntity httpEntity = new MyHttpEntity();
            httpEntity.setUrl("https://blog.51cto.com/357712148/" + param[i]);
            result[k++] = new Object[]{httpEntity};
        }
        return result;
    }

测试类

  @Test(dataProvider = "getparam", dataProviderClass = Dataprovidert.class, invocationCount = 20, threadPoolSize = 5)
    public void mydatep(MyHttpEntity httpEntity) {
        Long starttime = System.currentTimeMillis();
        HttpResponse response = HttpRequest.get(httpEntity.url).execute();
        Assert.assertTrue(response.body().contains("success"));
        Long endttime = System.currentTimeMillis();
        log.info("请求为:" + httpEntity.getUrl() + "时间为:" + (endttime - starttime) + "毫秒" + "结果:");

    }
    public static void geturl() {
        log.info("这是调用的Url数据测试一把" + new MyHttpEntity().getUrl());

    }

分享题目:testng多线程运行方式一
链接分享:https://www.cdcxhl.com/article2/jocooc.html

成都网站建设公司_创新互联,为您提供品牌网站建设动态网站关键词优化定制网站外贸网站建设ChatGPT

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

h5响应式网站建设