gpt4 book ai didi

java - 拉力赛(Java): I dont want to add a testresult if there is one already in the testcase

转载 作者:行者123 更新时间:2023-12-01 15:07:56 26 4
gpt4 key购买 nike

我正在发送一个查询来检查是否有与测试用例关联的测试用例结果。我正在使用这个:

    QueryRequest c = new QueryRequest("testcaseresult");
c.setFetch(new Fetch("testcase"));
c.setQueryFilter(new QueryFilter("testcase", "=", testCaseRef));
QueryResponse cc = r.query(c);

//String testresultRef = cc.getResults().get(0).getAsJsonObject().get("_ref").toString();

仅当到目前为止测试用例中没有 testcaseresult 时,我才想创建一个新的 testcaseresult。我怎样才能使用查询来做到这一点?谢谢。

最佳答案

我认为您在进行后续查询时处于正确的轨道上。但是您无法查询引用文献。但是,由于您有 ref,并且可能也有 TestCase JsonObject,因此您可以执行如下操作,在其中查询父 TestCase 的 FormattedID:

    // Query for Test Case to which we want to add results
QueryRequest testCaseRequest = new QueryRequest("TestCase");
testCaseRequest.setFetch(new Fetch("FormattedID","Name"));
testCaseRequest.setQueryFilter(new QueryFilter("FormattedID", "=", "TC4"));
QueryResponse testCaseQueryResponse = restApi.query(testCaseRequest);
JsonObject testCaseJsonObject = testCaseQueryResponse.getResults().get(0).getAsJsonObject();
String testCaseRef = testCaseQueryResponse.getResults().get(0).getAsJsonObject().get("_ref").toString();
String testCaseFormattedID = testCaseQueryResponse.getResults().get(0).getAsJsonObject.get("FormattedID").toString();

// Query for Test Case Results that are associated to this particular Test Case
QueryRequest testCaseResultsRequest = new QueryRequest("TestCaseResult");
testCaseResultsRequest.setFetch(new Fetch("Build","TestCase","Verdict","FormattedID"));
testCaseResultsRequest.setQueryFilter(new QueryFilter("TestCase.FormattedID", "=", testCaseFormattedID));
QueryResponse testCaseResultResponse = restApi.query(testCaseResultsRequest);
int numberTestCaseResults = testCaseResultResponse.getTotalResultCount();

关于java - 拉力赛(Java): I dont want to add a testresult if there is one already in the testcase,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12730026/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com