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

问题描述

我有用Java编写的硒自动化测试框架。与junit5和kiwi的junit-plugin集成。

我正在尝试根据我的自动测试结果来更新猕猴桃上的测试执行。首先,我想知道这可行吗?

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

    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();

任何帮助将不胜感激!

解决方法

我有用Java编写的硒自动化测试框架。集成 使用Junit5和猕猴桃的junit-plugin。

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

您已经看到了。

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

请参见此方法: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接受哪些参数以及如何进行查询。

请成为一名优秀的开源公民,并考虑在https://github.com/kiwitcms/api-scripts贡献您的Selenium胶水代码,以帮助其他有兴趣的人。

更新:

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

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

,

我现在很近:

有一些更新测试执行的方法:

kiwi.updateTestExecution(ExecutionId,status);

但我无法根据CaseID获取此 ExecutionId

enter image description here

如果我跑步:

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

我得到:

enter image description here

没有执行ID

,

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

完整示例:

        //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