我有一个这样的单元测试:
@Test
public void callRegisterByForm() {
// AnyContentAsJson anyContentAsJson = null;
running(fakeApplication(), new Runnable() {
@Override
public void run() {
Map<String, String> map = new HashMap<String, String>();
map.put("phoneNumber", "+5103978860");
map.put("countryCode", "us");
Result result = routeAndCall(fakeRequest("POST", "/register").withFormUrlEncodedBody(map));
assertThat(status(result)).isEqualTo(OK);
assertThat(contentType(result)).isEqualTo("application/json");
JsonNode jsonResult = Json.parse(contentAsString(result));
assertThat(jsonResult.get(Config.DEV_REG_STATUS_PARAM).asText()).isEqualTo("OK");
assertThat(jsonResult.get(Config.DEV_PHONE_NUMBER_PARAM).asText()).isEqualTo("+5103978860");
}
});
}
如何测试服务器的控制器?我尝试设置一个远程 java 应用程序并在控制台上使用“播放调试运行”,但仍然无法右键单击此测试用例来运行并使服务器的控制器在断点处停止。
这是我右键单击测试用例时的图像。它要求我选择要使用的启动器。