亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

更新 Cucumber 功能并在 Jira 中的 Xray 上測試執行結果

更新 Cucumber 功能并在 Jira 中的 Xray 上測試執行結果

12345678_0001 2023-06-28 15:55:37
我正在嘗試使用 Cucumber 和 Java 設置一個自動化框架。我使用 Itellij IDEA 作為我的 IDE。到目前為止,我能夠自動化測試用例。我閱讀了 Xray 文檔并意識到我應該使用 REST API 來更新 Xray 上的功能文件。我使用過 Cucumber 和 C#,在 Visual Studio 上自動化了我的測試用例,并使用 Hooks 更新了 TFS 上的功能和執行狀態。截至目前,我希望通過 Xray 使用 Java 實現相同的功能。我做了一些研究,意識到我應該在用 Cucumber 編寫的 Xray 上創建一個測試用例,然后將其導出以在 Intellij 上自動化,或者自動化測試用例并使用 Jenkins 在 Xray 上更新它們。是否有解決方法或教程可以讓我在 Intellij 上使用 Java 和 Cucumber 更新 Xray 上的功能?
查看完整描述

1 回答

?
慕村9548890

TA貢獻1884條經驗 獲得超4個贊

對于那些遇到與我相同問題的人,這是我能夠將黃瓜特征導出到 Xray 的方法。您只需發送 Cucumber 功能文件的路徑和 url,如下所示 - https://jira.yourdomain.com/rest/raven/1.0/import/feature其他參數很容易理解。

public static void importFeatureFilesToJira(String filePath, String resultTypeUrlValue){

    String jiraUrl = config.getJiraLoginValue();

    log.info(String.format("Starting upload of Cucumber features to XRAY on Jira project: %s\n Using Jira user: %s ", config.getJiraProjectValue(), config.getJiraLoginValue()));

    log.info(String.format("Path to Report: %s", filePath));

    String authentication = config.getJiraLoginValue() + ':' + config.getJiraPassword();

    BASE64Encoder encoder = new BASE64Encoder();

    String encoded = null;

    try {

        encoded = encoder.encode((authentication).getBytes("UTF-8"));

    } catch (UnsupportedEncodingException e) {

        e.printStackTrace();

    }

    Client client = ClientBuilder.newBuilder()

            .register(MultiPartFeature.class).property(HttpHeaders.AUTHORIZATION, encoded).build();


    //Import type is dynamic below

    StringBuffer url = new StringBuffer(resultTypeUrlValue);

    url.append("?projectKey=").append(config.getJiraProjectValue());

    WebTarget webTarget = client.target(url.toString());

    log.info(String.format("URL of the XRAY API: %s", url.toString()));

    MultiPart multiPart = new MultiPart();

    multiPart.setMediaType(MediaType.MULTIPART_FORM_DATA_TYPE);

    FileDataBodyPart fileDataBodyPart = new FileDataBodyPart("file",

            new File(filePath),

            MediaType.APPLICATION_OCTET_STREAM_TYPE);

    multiPart.bodyPart(fileDataBodyPart);


    Response response = webTarget.request(

            MediaType.MULTIPART_FORM_DATA)

            .accept(MediaType.APPLICATION_JSON).

                    header(HttpHeaders.AUTHORIZATION, "Basic " + encoded).post(

                    Entity.entity(multiPart, multiPart.getMediaType()));

    log.info(response.getStatus() + " "

            + response.getStatusInfo() + " " + response);

    int responseBody = response.getStatus();

    String responseBodySting = response.toString();

    try{

        if(responseBody==200 && responseBodySting.contains("200")){

            log.info("Cucumber features were uploaded successfully");

        }

    }catch (Exception e){

        log.info("There was an error uploading the Cucumber feature file");

    }

    log.info("End of XRAY file upload publication");

}


查看完整回答
反對 回復 2023-06-28
  • 1 回答
  • 0 關注
  • 299 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號