check json query result

JSONクエリの結果を期待される文字列と比較します。
名前説明タイプ修飾子
json

クエリが実行されるJSON対象ドキュメントです。

Stringなし
jsonpath

JSONPathクエリ文字列です。

Stringなし
expected

(任意)期待されるクエリの結果です。

Stringなし
文字列が一致した場合には「Passed」になり、それ以外の場合は「Failed」になります。
このアクションは、次のプロジェクト項目で使用できます: テストモジュールおよびユーザー定義アクションです。
次の設定はこのアクションに適用可能です:  remove double quotes from cells.

以下のJSONドキュメントの場合を想定します: 

        
            
{ "store": { "book": [ { "category": "reference", "author": "Nigel Rees", "title": "Sayings of the Century", "price": 8.95 }, { "category": "fiction", "author": "Evelyn Waugh", "title": "Sword of Honour", "price": 12.99 }, { "category": "fiction", "author": "Herman Melville", "title": "Moby Dick", "isbn": "0-553-21311-3", "price": 8.99 }, { "category": "fiction", "author": "J. R. R. Tolkien", "title": "The Lord of the Rings", "isbn": "0-395-19395-8", "price": 22.99 } ], "bicycle": { "color": "red", "price": 19.95 } } }
引数 json にJSONドキュメント全体の内容を挿入するため、例えば、 JSON Editor Online を使用して、全ての空白を削除します。 返されるJSONドキュメントは以下のようになります: 

{"store":{"book":[{"category":"reference","author":"Nigel Rees","title":"Sayings of the Century","price":8.95},{"category":"fiction","author":"Evelyn Waugh","title":"Sword of Honour","price":12.99},{"category":"fiction","author":"Herman Melville","title":"Moby Dick","isbn":"0-553-21311-3","price":8.99},{"category":"fiction","author":"J. R. R. Tolkien","title":"The Lord of the Rings","isbn":"0-395-19395-8","price":22.99}],"bicycle":{"color":"red","price":19.95}}}

        
            	json	jsonpath	expected
check json query result	{"store":{"book":[{"category":"reference","author":"Nigel Rees","title":"Sayings of the Century","price":8.95},{"category":"fiction","author":"Evelyn Waugh","title":"Sword of Honour","price":12.99},{"category":"fiction","author":"Herman Melville","title":"Moby Dick","isbn":"0-553-21311-3","price":8.99},{"category":"fiction","author":"J. R. R. Tolkien","title":"The Lord of the Rings","isbn":"0-395-19395-8","price":22.99}],"bicycle":{"color":"red","price":19.95}}}	store.book[0].category	reference
        
    
  • REST AssuredのJSONPathは、RESTベースのサービスのテストを簡素化するためのJavaフレームワークであり、現在はTestArchitectで使用されています。このヘルプシステムの範囲外でGPathに関するチュートリアルを提供することはできません。GPathについての詳細情報は、このサイトを参照してください。
  • 引数 expected が空の場合、返されたJSONが実際に空であれば「Passed」になり、それ以外の場合は「Failed」になります。
  • JSONドキュメント全体の内容を引数 json に挿入するには、自動化の失敗を避けるために全ての空白を手動で削除する必要があります。

    ヒント: 
    空白を削除するためにさまざまなツールを使用できます。例えば、JSON Editor Online を使用できます。

  • このアクションは修飾子 <ignore> をサポートしています。引数のいずれかの値として文字列 <ignore> が含まれているか、或いはどの引数かが <ignore> に評価される式を含んでいる場合、そのアクションは実行中にスキップされます。

Copyright © 2024 LogiGear Corporation. All rights reserved. LogiGear is a registered trademark, and Action Based Testing and TestArchitect are trademarks of LogiGear Corporation. All other trademarks contained herein are the property of their respective owners.

LogiGear Corporation

1730 S. Amphlett Blvd. Suite 200, San Mateo, CA 94402

Tel: +1 (650) 572-1400