[英]Testing Rest Api methods
I'have to test the functions in rest api class that i created, I'm unable to get the functions of the created api class inside the test class, I haven't do the testing coding before. 我必须测试我创建的rest api类中的功能,无法在测试类中获取所创建的api类的功能,我之前没有进行测试编码。 I need some guides to follow .
我需要一些指导。
@POST @POST
@Produces("text/plain")
@Path("/notifications/login/")
@HeaderParam("encoded")
Response login(@HeaderParam("encoded") String encoded, @QueryParam("tenantId") String tenantId) throws NotificationManagementException;
Its a function that i created, im not giving whole function body here, i need to know how to test this function. 它是我创建的功能,在这里我没有给出整个功能体,我需要知道如何测试该功能。 I'm giving a request call in javascript.
我正在用javascript发出请求调用。
Unless there is some reason why you really don't want to, you could make the method public
, and then you would be able to see it inside the test class. 除非出于某些原因您确实不想这么做,否则可以将方法设为
public
,然后可以在测试类中看到它。
ie 即
public Response login(...)
In the test you can then make a new instance of the class and call the method normally. 然后,在测试中,您可以创建该类的新实例并正常调用该方法。
eg 例如
@Test
public void shouldDoSomething(){
SomeClass someClass = new SomeClass();
someClass.login(...);
//some assertions or verifications
}
Two ways: 两种方式:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.