Search code examples
httpwebsocketerlangcowboygun

Passing ID of websocket connection between testcases (Common Test) , Erlang


Who can help me? I have server that based on websockets. I want to test API using common tests (CT) passing connection ID between testcases and using only one connection for all testcases. Test cases closes the connection.

Please, give me example if it's possible.


Solution

  • If you organize your test cases in groups and the groups in (test) suites, you can use the functions init_per_suite/1, end_per_suite/1, init_per_group/2, end_per_group/2, init_per_testcase/2 and end_per_test_case/2 to create and destroy all the resources you need, and keep them alive the necessary time. There is a Config2 you can pass around using the init's, and it is intended to be used for run time configuration.

    If you have trouble to pass the information to your testcases, you can store them in a registered server (a simple loop reacting to a couple of requests) that you spawn at the right init_per_XXX level and destroy at the corresponding end_per_XXX.

    See the example at learnyousomeerlang