如何将我的测试结果从 selenium 发送到 testrail
How to send my test results from selenium to testrail
我无法将我的测试结果从 selenium 发送到 testrail。我似乎无法使用提供的文书工作来解决这个问题。我目前正在使用这个:
public class login_errors extends ConditionsWebDriverFactory {
public static String TEST_RUN_ID = "R1713";
public static String TESTRAIL_USERNAME = "testemai9@hotmail.com";
public static String TESTRAIL_PASSWORD = "Password1";
public static String RAILS_ENGINE_URL = "https://testproj.testrail.com/";
public static final int TEST_CASE_PASSED_STATUS = 1;
public static final int TEST_CASE_FAILED_STATUS = 5;
@Test
public void login_errors() throws IOException, APIException {
Header header = new Header();
header.guest_select_login();
Pages.Login login = new Pages.Login();
login.login_with_empty_fields();
login.login_with_invalid_email();
login.email_or_password_incorrect();
login.login_open_and_close();
login_errors.addResultForTestCase(TEST_RUN_ID,TEST_CASE_PASSED_STATUS," ");
}
public static void addResultForTestCase(String testCaseId, int status,
String error) throws IOException, APIException {
String testRunId = TEST_RUN_ID;
APIClient client = new APIClient(RAILS_ENGINE_URL);
client.setUser(TESTRAIL_USERNAME);
client.setPassword(TESTRAIL_PASSWORD);
Map data = new HashMap();
data.put("status_id", status);
data.put("comment", "Test Executed - Status updated automatically from Selenium test automation.");
client.sendPost("add_result_for_case/"+testRunId+"/"+testCaseId+"",data );
}
}
但我不断收到以下异常:
com.gurock.testrail.APIException: TestRail API returned HTTP
401("Authentication failed: invalid or missing user/password or
session cookie.")
任何人都可以帮助我了解在 java 中应该完成的确切方法吗?我不确定我是否做对了。
我正在使用自己定制的 API 进行测试,但它们都是基于同一件事。
但是期待官方的 gurrock,
documentation
首先,您需要在 URL 端点的末尾添加 "testrail/",
APIClient client = new APIClient("http://<server>/testrail/");
client.setUser("..");
client.setPassword("..");
应该是这样的:
public static String RAILS_ENGINE_URL ="https://testproj.testrail.com/testrail/";
我发现的第二件事是,您正在为测试用例 ID 发送变量中的测试 运行 id,这不一样。
另一件事是测试用例 ID 前面不应该有任何纯数字,不像 "R123" 而是“123”
你的方法应该接受一个参数,testRunId
public static void addResultForTestCase(String testRunId, String testCaseId, int status,String error) throws IOException, APIException {
String testRunId = TEST_RUN_ID;
APIClient client = new APIClient(RAILS_ENGINE_URL);
client.setUser(TESTRAIL_USERNAME);
client.setPassword(TESTRAIL_PASSWORD);
Map data = new HashMap();
data.put("status_id", status);
data.put("comment", "Test Executed - Status updated automatically from Selenium test automation.");
client.sendPost("add_result_for_case/"+testRunId+"/"+testCaseId+"",data );
}
另一件事是您必须创建测试运行,这样您就可以拥有自己的测试运行 ID,如下图所示:
并且测试用例 ID 不同于测试运行 id。
我无法将我的测试结果从 selenium 发送到 testrail。我似乎无法使用提供的文书工作来解决这个问题。我目前正在使用这个:
public class login_errors extends ConditionsWebDriverFactory {
public static String TEST_RUN_ID = "R1713";
public static String TESTRAIL_USERNAME = "testemai9@hotmail.com";
public static String TESTRAIL_PASSWORD = "Password1";
public static String RAILS_ENGINE_URL = "https://testproj.testrail.com/";
public static final int TEST_CASE_PASSED_STATUS = 1;
public static final int TEST_CASE_FAILED_STATUS = 5;
@Test
public void login_errors() throws IOException, APIException {
Header header = new Header();
header.guest_select_login();
Pages.Login login = new Pages.Login();
login.login_with_empty_fields();
login.login_with_invalid_email();
login.email_or_password_incorrect();
login.login_open_and_close();
login_errors.addResultForTestCase(TEST_RUN_ID,TEST_CASE_PASSED_STATUS," ");
}
public static void addResultForTestCase(String testCaseId, int status,
String error) throws IOException, APIException {
String testRunId = TEST_RUN_ID;
APIClient client = new APIClient(RAILS_ENGINE_URL);
client.setUser(TESTRAIL_USERNAME);
client.setPassword(TESTRAIL_PASSWORD);
Map data = new HashMap();
data.put("status_id", status);
data.put("comment", "Test Executed - Status updated automatically from Selenium test automation.");
client.sendPost("add_result_for_case/"+testRunId+"/"+testCaseId+"",data );
}
}
但我不断收到以下异常:
com.gurock.testrail.APIException: TestRail API returned HTTP 401("Authentication failed: invalid or missing user/password or session cookie.")
任何人都可以帮助我了解在 java 中应该完成的确切方法吗?我不确定我是否做对了。
我正在使用自己定制的 API 进行测试,但它们都是基于同一件事。
但是期待官方的 gurrock, documentation
首先,您需要在 URL 端点的末尾添加 "testrail/",
APIClient client = new APIClient("http://<server>/testrail/");
client.setUser("..");
client.setPassword("..");
应该是这样的:
public static String RAILS_ENGINE_URL ="https://testproj.testrail.com/testrail/";
我发现的第二件事是,您正在为测试用例 ID 发送变量中的测试 运行 id,这不一样。
另一件事是测试用例 ID 前面不应该有任何纯数字,不像 "R123" 而是“123”
你的方法应该接受一个参数,testRunId
public static void addResultForTestCase(String testRunId, String testCaseId, int status,String error) throws IOException, APIException {
String testRunId = TEST_RUN_ID;
APIClient client = new APIClient(RAILS_ENGINE_URL);
client.setUser(TESTRAIL_USERNAME);
client.setPassword(TESTRAIL_PASSWORD);
Map data = new HashMap();
data.put("status_id", status);
data.put("comment", "Test Executed - Status updated automatically from Selenium test automation.");
client.sendPost("add_result_for_case/"+testRunId+"/"+testCaseId+"",data );
}
另一件事是您必须创建测试运行,这样您就可以拥有自己的测试运行 ID,如下图所示:
并且测试用例 ID 不同于测试运行 id。