Recently we have been developing an application that uses Phoenix channels. It has rooms that users can join and each room has a state which is managed through a genserver. The room channel handles various messages and delegates to the genserver which has the corresponding functions for most of the messages. We are doing it the TDD way and I really like that, but I have a feeling that we have written too much tests and it’s become a big mess. The fact is that both the genserver and the channel are covered with tests that mostly test the same things twice. A lot of the times when I changed something I had to change both the channel and the genserver tests. I think the reason why this test suite ended up like that is that the channel and the genserver were developed simultaneously and almost separately by 2-3 people, mostly beginners in this area.
I want to develop a similar application on my own and would like to not make the same mistakes again, so I would like to confirm that what I’m thinking is right. My takeaway from this is that there’s no need to write unit tests for genservers, since the only thing that’s really exposed is the channel. I would decouple the tests from the implementation and just test the exposed behavior. 1. Do you agree?
2. Is there a scenario where it makes sense to write unit tests for genservers?
3. Is it worth the time and effort to clean up the test suite of our existing project?
4. Are there any tools which could tell me if a test is obsolete?