Java 测试 Web 服务的库

7
我为REST web服务编写了JUnit测试。现在我认为JUnit不是最好的工具,因为这些测试是集成测试而不是单元测试。所以我可能需要一个Java库,它可以帮助发送HTTP请求,验证HTTP响应,创建报告并并行执行。
另一方面,也许我错了,JUnit(与HTTPUnit等)已经足够好了,我不需要其他工具。
你会建议什么?
2个回答

2
保持简单。看一下https://github.com/valid4j/http-matchers
// Statically import the library entry point:
import static org.valid4j.matchers.http.HttpResponseMatchers.*;

// Invoke your web service using plain JAX-RS. E.g:
Client client = ClientBuilder.newClient();
Response response = client.target("http://example.org/hello").request("text/plain").get();

// Verify the response
assertThat(response, hasStatus(Status.OK));
assertThat(response, hasHeader("Content-Encoding", equalTo("gzip")));
assertThat(response, hasEntity(equalTo("content")));
// etc...

2

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接