ロボットフレームワークでテストケースを作成しようとしています。ロボットフレームワークの関数とJson結果を比較する
私たちは結果として私たちにJsonを返す残りの2つのapiを持っています。そのような場合を起動するには、我々はファイル出力の内部JSONを保存rest2.py
def restJSON():
r = requests.get("http://httpbin.org/get")
# print "Code" , r.status_code
# print "Text " , r.text
return r.json()
に次のコードを使用していました。そして、我々は
*** Settings ***
Library rest2.py
Library OperatingSystem
*** Test Cases ***
Example that calls a python keyword
${result}= restJSON
${json}= Get file output
Should be equal ${result} ${json}
以下のようにJSONの比較を評価するために、ロボットのテストケースを書かれている。しかし、我々はpybotのテストケースを実行すると、我々は両方のJSONが同じではないというエラーを取得しています。
--------------------------------
pybot testSuite.txt
--------------------------------
==============================================================================
testSuite
==============================================================================
Example that calls a python keyword | FAIL |
{u'origin': u'10.252.30.94, 69.241.25.16', u'headers': {u'Via': u'1.1 localhost (squid/3.1.14)', u'Accept-Encoding': u'gzip, deflate, compress', u'Accept': u'*/*', u'User-Agent': u'python-requests/2.2.1 CPython/2.7.6 Linux/3.16.0-30-generic', u'Host': u'httpbin.org', u'Cache-Control': u'max-age=259200'}, u'args': {}, u'url': u'http://httpbin.org/get'} != {u'origin': u'10.252.30.94, 69.241.25.16', u'headers': {u'Via': u'1.1 localhost (squid/3.1.14)', u'Accept-Encoding': u'gzip, deflate, compress', u'Accept': u'*/*', u'User-Agent': u'python-requests/2.2.1 CPython/2.7.6 Linux/3.16.0-30-generic', u'Host': u'httpbin.org', u'Cache-Control': u'max-age=259200'}, u'args': {}, u'url': u'http://httpbin.org/get'}
------------------------------------------------------------------------------
testSuite | FAIL |
1 critical test, 0 passed, 1 failed
1 test total, 0 passed, 1 failed
==============================================================================
jsonファイルは同じです。しかし、まだ失敗している両方のテストケースは同じではありません。これを比較する正しい方法か、それともロボットフレームワークで他の方法を使用する方法がありますか?