java - Writing unit tests for network related classes -


I have a class that is responsible for network communication. I want to test a unit for this.

Here is the place where I am stuck in writing a test for it, I have to implement a server to communicate with it, but instead it will need

Unless you are writing a low-level driver, your class will undoubtedly make real communication to other sections Depends on. In that event, I would use dependency injection for the supply of those sections or wrappers, if they would not be able to joke easily. In your testing, you will provide a fake version of those classes that you (or wrappers if you can not duplicate genuine classes). Verify that the correct methods with the appropriate criteria are implemented by you in your manner that is supplied by you. Ensure that you have enough unit tests to satisfy yourself that you have covered the entire range of behavior with genuine dependence, it will be enough for your unit tests.

You will also need some integration tests. Unfortunately, the easiest way to do this is to develop a full-up counterfeit server to develop. Note that your counterfeit server needs to implement the interface - not the actual code at the other end. Supply some additional methods to allow the server to be set up for your integration test so that there is expected behavior with the fake server.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -