英文:
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包含status
和execution_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
if i run:
TestCase[] testCases = kiwi.getRunIdTestCases(2);
I get:
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("username", "password");
//every selenium test case should have assigned case id (from kiwi)
int runId = "your_run_id";
//search for execution ID based on case ID and run 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();
//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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论