Kiwi-tcms | junit-plugin | 无法将测试结果发布到Kiwi

huangapple go评论73阅读模式
英文:

Kiwi-tcms | junit-plugin | Not able to publish test results to Kiwi

问题

我有一个用JAVA编写的Selenium自动化测试框架。集成了Junit5和kiwi的junit-plugin。

我正在尝试根据我的自动化测试结果更新基于kiwi的测试执行。首先,我想知道这是否可行?

我能够创建连接并登录,但是没有熟悉的方法来更新特定测试用例的测试执行。

RpcClient kiwi = new RpcClient();
kiwi.login("my_username", "my_password");
//我需要在这里添加类似于
kiwi.updateTestCaseExecution("specific_test_run", "specific_test_case", "test_status");
kiwi.logout();

任何帮助将不胜感激!

英文:

I have selenium automation test framework written in JAVA. Integrated with Junit5 and kiwi's junit-plugin.

Im trying to update test execution on kiwi based on my automated test result. First, im wondering is that doable?

Im able to create connection and login, but there are no familiar methods to update test execution for specific test case.

    RpcClient kiwi = new RpcClient();
    kiwi.login("my_username", "my_password");
    //I need here something like 
    kiwi.updateTestCaseExecution("specific_test_run", "specific_test_case", "test_status");
    kiwi.logout();

Any help would be appreciated!

答案1

得分: 2

以下是您要翻译的内容:

我有一个用JAVA编写的Selenium自动化测试框架。已与Junit5和kiwi的junit-plugin集成。

我正在尝试根据我的自动化测试结果更新基于kiwi的测试执行。首先,我想知道这可行吗?

正如您已经看到的那样。

我能够创建连接并登录,但是没有熟悉的方法来更新特定测试用例的测试执行。

请参阅此方法:https://github.com/kiwitcms/junit-plugin/blob/master/src/main/java/org/kiwitcms/java/api/RpcClient.java#L243 第一个参数是TE ID,第二个参数是状态ID。

我无法根据CaseID获取此ExecutionId。

您需要使用TestExecution.filter()按runId和caseId进行过滤:
https://github.com/kiwitcms/junit-plugin/blob/master/src/main/java/org/kiwitcms/java/api/RpcClient.java#L228

还请参阅https://kiwitcms.readthedocs.io/en/latest/modules/tcms.rpc.api.html#module-tcms.rpc.api 以获取有关API接受哪些参数以及如何进行查询的信息。

请成为一个好的开源社区成员,考虑将您的Selenium glue代码贡献到https://github.com/kiwitcms/api-scripts,以帮助其他可能感兴趣的人。

更新:

TestCase[] testCases = kiwi.getRunIdTestCases(2);

基础TestRun.get_cases() API方法返回的原始JSON包含statusexecution_id字段,但是junit-plugin库中的Java序列化代码会忽略它们,因为它们不是TestCase模型的一部分,请参阅model/TestCase.java

英文:

> I have selenium automation test framework written in JAVA. Integrated
> with Junit5 and kiwi's junit-plugin.
>
> Im trying to update test execution on kiwi based on my automated test
> result. First, im wondering is that doable?

As you have already seen it is.

> Im able to create connection and login, but there are no familiar
> methods to update test execution for specific test case.

See this method: https://github.com/kiwitcms/junit-plugin/blob/master/src/main/java/org/kiwitcms/java/api/RpcClient.java#L243 First parameter is the TE ID, the second one is a status ID.

> I cannot get this ExecutionId based on CaseID

You need TestExecution.filter() to filter by runId and caseId:
https://github.com/kiwitcms/junit-plugin/blob/master/src/main/java/org/kiwitcms/java/api/RpcClient.java#L228

Also see https://kiwitcms.readthedocs.io/en/latest/modules/tcms.rpc.api.html#module-tcms.rpc.api for information what parameters are accepted by the API and how to make queries.

Please be a good open source citizen and consider contributing your Selenium glue code at https://github.com/kiwitcms/api-scripts to help others who may be interested.

Update:

> TestCase[] testCases = kiwi.getRunIdTestCases(2);

The raw JSON returned by the underlying TestRun.get_cases() API method contains both status and execution_id fields but the Java serializer code in the junit-plugin library ignores them b/c they aren't part of the TestCase model, see model/TestCase.java.

答案2

得分: 0

我现在非常接近:

有一种方法可以更新测试执行:

kiwi.updateTestExecution(ExecutionId, status);

但是我无法根据 CaseID 获取这个 ExecutionId

如果我运行:

TestCase[] testCases = kiwi.getRunIdTestCases(2);

我会得到:

这里没有执行 ID。

英文:

I'm very close now:

there are method for updating Test Execution:

kiwi.updateTestExecution(ExecutionId,status);

but I cannot get this ExecutionId based on CaseID

Kiwi-tcms | junit-plugin | 无法将测试结果发布到Kiwi

if i run:

TestCase[] testCases = kiwi.getRunIdTestCases(2);

I get:

Kiwi-tcms | junit-plugin | 无法将测试结果发布到Kiwi

there are no Execution ID

答案3

得分: 0

感谢 https://stackoverflow.com/users/1431647/alexander-todorov

完整示例:

//创建客户端实例
RpcClient kiwi = new RpcClient();

//登录
kiwi.login("用户名", "密码");

//每个 Selenium 测试用例都应有分配的案例 ID(来自 kiwi)
int runId = "your_run_id";

//根据案例 ID 和运行 ID 搜索执行 ID
Map<String, Object> params = new HashMap<>();
params.put("run_id", runId);
params.put("case_id", "your_case_id");
TestExecution tcExec = kiwi.getTestExecution(params);
int tcExecId = tcExec.getTcRunId();

//使用结果更新执行
kiwi.updateTestExecution(tcExecId, 5);

//测试状态
//1 - 空闲
//2 - 运行中
//3 - 暂停
//4 - 通过
//5 - 失败
//6 - 阻塞
//7 - 错误
//8 - 被豁免

英文:

Thank you https://stackoverflow.com/users/1431647/alexander-todorov

full example:

        //create client instance
        RpcClient kiwi = new RpcClient();

        //login
        kiwi.login(&quot;username&quot;, &quot;password&quot;);

        //every selenium test case should have assigned case id (from kiwi)
        int runId = &quot;your_run_id&quot;;

        //search for execution ID based on case ID and run ID
        Map&lt;String, Object&gt; params = new HashMap&lt;&gt;();
        params.put(&quot;run_id&quot;, runId);
        params.put(&quot;case_id&quot;, &quot;your_case_id&quot;);
        TestExecution tcExec = kiwi.getTestExecution(params);
        int tcExecId = tcExec.getTcRunId();

        //update execution with results
        kiwi.updateTestExecution(tcExecId, 5);

        //test statuses
        //1 - IDLE
        //2 - RUNNING
        //3 - PAUSED
        //4 - PASSED
        //5 - FAILED
        //6 - BLOCKED
        //7 - ERROR
        //8 - WAIVED

huangapple
  • 本文由 发表于 2020年10月22日 20:46:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/64482548.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定