I've written an Android wireless communication library that is, by nature, multi-threaded, multi-process, and (of course) multi-device.
Are there effective testing libraries/frameworks for code of this nature in the Android world?
- Unit testing the multi-threaded code is hard for obvious reasons. Unit tests don't play nice with threads. (For example) How do I unit test a function that needs to wait for a Broadcast?
- Most of the errors seem to be limited to the "real world". The library requires two devices to talk to each other. If I mock a perfect response sequence, it just feels like cheating. Nothing ever goes wrong, unlike in the real world. Also, the mocking process is complex and time consuming -- I write way more code mocking than in the actual library.
- All of the testing frameworks on Android, Instrumented or otherwise, are for one device at a time. I can't run simultaneous, co-dependent tests on two devices at once, can I?
I only have a system-level test at this time, and it's mostly Ad hoc. It's just a regular application with a simple controller script, that pushes the app to two devices, assigns their roles, runs the high-level functionality test, and polls for a log file on both devices. If a timeout is reached before the log files are written, the script returns an error code. If the logs ARE written, the communication sequence is checked for correctness. This test could, in theory, be added to CI, but it would need to run from a local test machine with physically connected devices. I can make this test more robust with time, but right now it's very fragile. Again, I made it for this specific project.
I'm unsure of my approach here. Are the any existing tools in the Android ecosystem that can help me test this kind of project? Any advice or push in the right direction would be appreciated.
Aucun commentaire:
Enregistrer un commentaire