I'm new to software development and I am writing some functions that send data to and ask for data from a server. If I wanted to use test driven development when writing these functions, what would be the best way to go about doing it? The entire point of the function is sending data to/requesting data from the server, so obviously I should be testing to make sure the server is receiving the requests correctly and that the client is receiving data correctly. Should I attempt to get code implemented both client-side and server-side, to test the function output? With TDD already being a very time consuming way of developing software, having to implement code on both the client and server for every new test seems excessively time consuming.
Lets assume that you go with the TDD approach to writing your tests. In this case you should be focusing on writing tests for the code you are implementing. If in this case you are working on client side code that makes calls to a server you should be working with unit tests initially that test the calls you are making. Using stubs and mock objects you can impersonate the server interaction to build out the expected calls and responses you should get. Your will likely have a series of tests for the submissions and a series of tests for the responses.
The next step might be to build some integration tests that allow you to test the interactions between your client side code and the server. In this case you may have a test that wraps several methods and reflects how they work together. In this case the server is a bit of a black box. Assuming you get the responses back that you expect this gives lets you know that your code is playing nice with the server.