1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Amazon API GatewayでAPIの不具合を再現

Last updated at Posted at 2018-11-18

アプリケーションでAPIの不具合時のテストをしたいことってあると思います。

結論

Amazon API GatewayのMock機能を使うと、あらゆるクエリに対して一律のエラー系のステータスコードを返却でき、APIの不具合を再現可能できる。

手順

API Gatewayのリソースとパスはすでに作成済みとします。作成はこちらなどが参考になります。

1.統合リクエスト

統合リクエストでMockを選択し、statusCodeに返却したいステータスコードを指定します。デフォルトは200ですが、今回は不具合を再現したいので500をセットすることにします。

image.png

{"statusCode": 500}

2. メソッドレスポンス

メソッドレスポンスに返却したいステータスコードを追加

image.png

3. 統合レスポンス

結合レスポンスのマッピングテンプレートに、返却値を設定

image.png

4. 確認

テストを実行し、期待する返却値が得られることを確認します。

Pasted_Image_2018_11_20_11_26.png

image.png

ステータス500で、設定したレスポンスが返ってきました。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?