News for hackers. Stuff that matters.
Re:Write tests. Not too many. Mostly integration by leftsidedhorn on Friday October 27, 2017 @05:49AM (#15566956)
How do you deal with http interactions in test? Do you mock it or maybe save it to disk to replay later?
Re:Write tests. Not too many. Mostly integration by cjsuk on Friday October 27, 2017 @05:57AM (#15566996)
That's an integration test really. The clients all have an abstraction around the http endpoints so nothing touches integration in unit tests. The advantage of this is you deal with transfer objects only in the code, no HTTP which would violate separation of concerns.

I use HttpMock myself in test cases which fires up an http server for personal projects. We use Wiremock commercially.

Re:Write tests. Not too many. Mostly integration by mohaine on Friday October 27, 2017 @08:54AM (#15567802)
Here is how I handle it

1) Write a test that runs the service and saves output to a file. 2) Mock out the call to just return the data from the file and validate results. 3) If you need variations on this data just modify the file/data (often as part of the test)

I usually leave number 1 in the code but disabled since it often relies on remote data that may not be stable. Having the test run more than once is not very beneficial but being able to run it later and see what exactly has changed is great.