私は同僚との意見の不一致を抱えています。私は両側のコミュニティの考えを紹介したいと思います(または、さらに良い第3の選択肢)。テスト戦略:応答の「機能」をアサートするか、完全な応答を主張しますか?
基本的には、友だちリストを返すJSON APIがあります。結果は次のようになります。
[{"name":"Bob", "uid":12345, "level":4}, {"name":"George", "uid":23456, "level":6}]
応答に影響する通常の「相互友人」の要件があります。
意見の相違は、その上には優れている基本的には、応答の "機能" を主張
テストです:リテラルの応答に主張
def test_results_are_sorted_by_name(): .. <setup 2 friends> .. response = controller.getFriendsList() assertLessThan(response[0].name, response[1].name) def test_blocked_users_are_not_returned(): .. <setup some friends and block one, storing the id in blocked_uid> .. response = controller.getFriendsList() for friend in response: assertNotEqual(friend.uid, blocked_uid)
テスト
def test_results_are_sorted_by_name(): .. <setup 2 friends> .. response = controller.getFriendsList() expectedResponse = {...} assertEqual(response, expectedResponse) def test_blocked_users_are_not_returned(): .. <setup some friends and block one, storing the id in blocked_uid> .. response = controller.getFriendsList() expectedResponse = {...} assertEqual(response, expectedResponse)
どちらがいいですか、なぜですか?
他にも2つのオプションがありますか?ここ
「どちらが良いですか」という質問は、「質問しない」カテゴリの質問に該当します。http://stackoverflow.com/faq#dontask – Kev