JavaPhoenixChannels
JavaPhoenixChannels copied to clipboard
Improving tests
I've been thinking about how we can improve the tests here for a while now. It is a bit hard since we have to test against a Phoenix Channel server. One thought I had is maybe embedding a phoenix project in here that we could run and test against only when testing. The other option is mocking responses. Also interested in better ways to write the tests here.
Any thoughts or suggestions?
In an ideal world with lots of time, do both, haha.
Looks like maybe mockwebserver from okhttp can mock out websockets. But I wasn't sure if this library only speaks to Phoenix channels (I'm ignorant as to how those differ from say a Node/Socket.io websocket) or not.
I think it would be a win to have a simple Phoenix app and have a test that happens at an "integration" level. In our current case we go through that process of testing web socket connections manually with the server team. So I'm not sure we'd ever run that in an automated suite, but it makes it nice to just roll over to a test and hit "Run" from within Android Studio.
I went with the first option when I was facing the same issue in Scala land. Since the protocol wasn't really specified anyway, I decided to use an echo app to discover and test it, bundled it together in a Docker image and use that to test locally and on CircleCI.
@virtualandy I saw that as well. That might be the way to go. Phoenix Channels are just a protocol on top of websockets (or other transports) So mockwebserver and its websocket mocking would work here.
@Taig that's a great idea! Maybe something to look into if we set up some integration testing and CI here.
@bryanjos Feel free to have a look at my Docker/CircleCI configuration: https://github.com/taig/akka-http-phoenix