Open 5Mixer opened 8 years ago
I think creating localhost sockets and have them talk to each other could be one way to test. Simulating shitty networks is a task in itself though, so I think you're better off just running something like clumsy (https://github.com/jagt/clumsy) during the tests.
Thanks for the link @Ohmnivore, I'll try and look into simulating conditions in the future.
Tonight I've started with unit tests. There is a test that creates a client and server, and if the client sends a message that the server properly receives, the test is valid. It uses a timeout variable etc. I didn't honestly think mphx could run both a client and a server on the one thread, but the test shows it's possible. I'm glad I've got this test in, at least now some of the codebase is tested against syntax errors etc.
Feel free to contribute tests/code, as per usual. :)
@Ohmnivore Great find Thank you, definitely will be using this :+1:
Unit tests would be good to ensure that updates don't break the library. Being a networking library however, this is rather difficult. Even mocking connections can't really test the library fully as the most basic functionality of the library is to establish a real connection over the web. Unit tests rely on code always working - they don't factor in dodgy internet connections, the lag of the real world, or what happens to servers under pressure.
I'll have to do some more reading on this. Let me know if you have any input.