TestNG 看不到所有带注释的测试

TestNG does not see all annotated tests

我有 2 个用 @Test 注释的 TestNG 测试用例。一个方法有一个 return 类型的字符串,它也是一个测试用例。另一个使用第一个的输出参数。当我 运行 都测试时,TestNG 只显示只有一个 运行 而不是 2.

public class Login {

    private static String INITIATE = "https://login.endpoint.com/initiate";
    private static String COMPLETE = "https://login.endpoint.com/complete";

    @SuppressWarnings("unchecked")
    @Test(groups = "middleware", priority = 1)
    public String InitiateLogin() throws FileNotFoundException, UnsupportedEncodingException {
        RequestSpecification request = RestAssured.given();
        request.header("Content-Type", "application/json");
        JSONObject json = new JSONObject();
        json.put("email", "test@test.com");
        json.put("password", "111111");
        request.body(json.toJSONString());
        Response response = request.post(INITIATE);
        String OTP = response.path("OTP");

        if(OTP.matches("[0-9]{4}")) {
            response.then().body(
                    "OTP", equalTo(OTP));
        }
        return OTP;
    }

    @SuppressWarnings("unchecked")
    @Test(groups = "middleware", priority = 2)
    public void CompleteLogin() throws FileNotFoundException, UnsupportedEncodingException {

        RequestSpecification completeRequest = RestAssured.given();
        completeRequest.header("Content-Type", "application/json");
        JSONObject completeJson = new JSONObject();
        completeJson.put("Otp", InitiateDeviceRelease());
        completeRequest.body(completeJson.toJSONString());
        Response completeResponse = completeRequest.post(COMPLETE);
        completeResponse.then().body(
                "SessionToken", equalTo("ewrtw4456765v543fw3v"));

    }
}

这是测试的输出。它应该显示 2 个测试用例 运行,但它只能显示一个 运行。是因为第一个测试有一个 return 类型而不是 void 吗?我怎样才能让 testng 看到它们是 2 个测试用例?

{
    "OTP": "6645"
}
PASSED: CompleteLogin

===============================================
    Default test
    Tests run: 1, Failures: 0, Skips: 0
===============================================


===============================================
Default suite
Total tests run: 1, Failures: 0, Skips: 0
===============================================

@测试方法不能有return类型,它应该总是void。

尝试将 InitiateLogin() 方法的 return 类型更改为 void,应该可以。