0
0

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 1 year has passed since last update.

Postmanでテストを書く

Last updated at Posted at 2022-08-03

Postmanでテストを書く機会があったのでメモです

参考

公式ドキュメント

APIのレスポンス参照

let response = pm.response //.json()を末尾につけるとparseされる;

テストブロック

pm.test("テストの説明", function () {
    // テストする内容
});

ステータスコードのテスト

pm.test("StatusCode == 200", function () {
    pm.response.to.have.status(200);
});

## レスポンス(JSON)のパラメータテスト

pm.test("Parameter test", function () {
    pm.response.to.have.jsonBody("key1")
    pm.response.to.have.jsonBody("key2")
    pm.response.to.not.have.jsonBody("key3") // 持っていないこと
});

値の比較

pm.test("eql Check", function () {
    pm.response.to.eql('A'); // == A
    pm.response.to.not.eql('B'); // != B
});

環境変数への格納

pm.environment.set("updatedAt")

環境変数の参照

pm.environment.get("updatedAt")

以上

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?