8000 Expose Test Server · Issue #46 · dominicletz/websockex · GitHub
[go: up one dir, main page]

Skip to content

Expose Test Server #46

Open
Open

Description

@dpick

I'd like to write unit tests around my web socket message handling and I haven't been able to think of a good way to assert on the response my code sends back to the socket. It looks like in the tests for websockex you implement a fake server and connect a client to it to test things. Could you expose that server so that consumers of their library can make use of it as well?

I'm also open to other suggestions as well if anyone has other ideas.

Activity

  1. Azolo commented on Dec 30, 2017

    @Azolo
    Collaborator

    Hmm, so there's nothing "fake" about the server. It's a full blown Plug/Cowboy server that I start an instance of before each test that starts at a random port in the 50k-63k range. If the port is in use then I go to the next port.

    https://github.com/Azolo/websockex/blob/master/test/support/test_server.ex

    I could extract the root of that out into a Bare WebSocket Server, but it may be easier just to write up something on how to do it yourself. Let me think on it.

  2. Azolo commented on Dec 30, 2017

    @Azolo
    Collaborator

    Also, incase you were wondering, the overhead of starting a actual server is almost nothing. The WebSockex test suite run in like 4 seconds, and if I were to take the WebSocket properly closing to spec tests out it would probably be more like < 1 second.

  3. dpick commented on Dec 30, 2017

    @dpick
    Author

    👍 I'm actually much more comfortable spinning up a real server rather than mocking it out as well. An example of how to test something that uses WebSockex would probably be useful for people though. At least it would be for me 😄 .

  4. zacck-zz commented on Dec 25, 2018

    @zacck-zz

    Would it be possible to expose|document this in such a way that it is usable like the Tesla.Mock.
    This way developers can quickly setup Mocks and use them to do integration testing when using the library .... If it's possible and would need work ... I have hands to offer :)

    Thank you so much for the awesome library

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0