comparing two REST services to each other

前端 未结 3 1649
礼貌的吻别
礼貌的吻别 2021-01-16 22:04

Does anyone have any tips on writing tests that compare two REST services? We are doing this as a form of regression testing.

I was hoping to do something along the

相关标签:
3条回答
  • 2021-01-16 22:28

    I would use jUnit and some of the example test cases from the Jersey source as a starting point. Without knowing specifically how you want to determine "identical" responses, you can make a request to each in your test case and iterate through the response, convert it to a string and test for equals(), etc. Here is an example of a JSONP from JAXB test.

    0 讨论(0)
  • 2021-01-16 22:31

    Since this is a broad, non-coding question not strictly related to java, here are some related links:

    • The twitter open-source Diffy server, comparing primary, secondary and candidate endpoints: https://github.com/twitter/diffy
    • a similar, simpler http proxy: https://github.com/xthexder/httptee
    • Someone doing this using JMeter: https://dzone.com/articles/the-easiest-way-to-compare-rest-api-responses-usin
    • An Example using Postman post-response hooks to compare requests: https://documenter.getpostman.com/view/33232/difference-between-two-responses/2QsCkC
    • The Postman approach but using newman, a postman CLI client: https://github.com/indeedeng-alpha/newman-reporter-diff

    Anyone feel free to edit my answer to add more alternatives demonstrating API response comparison

    0 讨论(0)
  • 2021-01-16 22:37

    Write Junit to get the response objects from both services. And then do the comparison in Java as you do normally for the objects.

    But why do you have to write two services that does the same thing and return same results? Atleast I assume the response objects schema is different between two services.

    0 讨论(0)
提交回复
热议问题