简体   繁体   English

在 Jira 中更新 Xray 上的 Cucumber 功能和测试执行结果

[英]Update Cucumber features and test execution results on Xray in Jira

I'm trying to setup an automation framework with Cucumber and Java.我正在尝试使用 Cucumber 和 Java 设置一个自动化框架。 I'm using Itellij IDEA as my IDE.我使用 Itellij IDEA 作为我的 IDE。 I am able to automate the test cases as of now.到目前为止,我能够自动化测试用例。 I read the Xray documentation and realised that I should use the REST API to update the feature files on Xray.我阅读了 Xray 文档并意识到我应该使用 REST API 来更新 Xray 上的功能文件。

I have worked a bit with Cucumber and C# where I automated my test cases on Visual Studio and updated the features and execution status on TFS using Hooks.我在 Cucumber 和 C# 方面做了一些工作,我在 Visual Studio 上自动化了我的测试用例,并使用 Hooks 更新了 TFS 上的功能和执行状态。 As of now, I wish to implement the same with Java over Xray.到目前为止,我希望通过 Xray 使用 Java 实现相同的功能。

I have done a bit of research and realised that either I should create a test case on Xray written in Cucumber and then export it to automate on Intellij or automate the test cases and use Jenkins to update them on Xray.我做了一些研究,并意识到我应该在用 Cucumber 编写的 Xray 上创建一个测试用例,然后将其导出以在 Intellij 上自动化,或者自动化测试用例并使用 Jenkins 在 Xray 上更新它们。

Is there a work around or a tutorial which I can follow to update my features on Xray using Java and Cucumber on Intellij?是否有解决方法或教程可以让我在 Intellij 上使用 Java 和 Cucumber 更新我在 Xray 上的功能?

For those who're stuck with the same problem as mine, this is the way that I am able to export my cucumber features to Xray.对于那些遇到和我一样问题的人来说,这是我能够将黄瓜特征导出到 Xray 的方式。 You just have to send the path of your Cucumber feature file and the url like this - https://jira.yourdomain.com/rest/raven/1.0/import/feature The other parameters are quite understandable.你只需要像这样发送你的 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");
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从黄瓜中的功能生成java测试类 - Generate java test class from features in cucumber 在Maven中设置cucumber-jvm格式选项以附加所有测试执行结果 - Setting cucumber-jvm format options in Maven to append all test execution results 使用 Azure Devops 将自动化测试结果导入 Xray Cloud multipart - Import automated test results to Xray Cloud multipart using Azure Devops 如何使用 cucumber 挂钩退出测试执行 - How to quit test execution using cucumber hooks 在Java中执行的黄瓜测试步骤时间 - Cucumber Test Step time of execution in Java Jenkins:Cucumber 测试运行程序执行顺序 - Jenkins: Cucumber Test Runners execution order Cucumber 如何使用不同的被测代码多次运行功能? - Cucumber how to run features multiple times with different code under test? 使用与黄瓜集成的柑橘框架进行并行集成测试执行 - Parallel integration test execution using citrus framework integrated with cucumber Cucumber JVM 4.0.0和Junit测试运行程序不会发生并行执行 - Parallel Execution not happening with Cucumber JVM 4.0.0 and Junit test runner JUnit 5 + Cucumber 并行测试执行不适用于文件安全(Maven) - JUnit 5 + Cucumber parallel test execution doesn't work with filesafe (Maven)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM