7

JUnitREST Web サービスのテストがあります。これらのテストは統合テストであり、単体テストJUnitではないため、これは最適なツールではないと思います。したがって、HTTP 要求の送信、HTTP 応答の検証、レポートの作成、およびそれを並行して行うのに役立つ Java ライブラリーがおそらく必要です。

一方、私は間違っているかもしれませんが、Junit(with HTTPUnitetc.) で十分であり、他のツールは必要ありません。

何を提案しますか?

4

2 に答える 2

2

私も同様の質問に直面しています...そして周りを見回して実験し始めています。

これは別のstackoverflowの質問であることがわかりました: Unit testing a JAX-RS Web Service? (どうやらJerseyはそのようなタイプのテストを行うことを許可しています)。

これらは、ポップアップした2つのオプションです。

于 2013-07-13T11:21:44.917 に答える
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...
于 2016-01-28T08:30:54.710 に答える