<!DOCTYPE html>
<html><head>
<meta charset="UTF-8">
</head><body><p>Hello,<br></p><p>I wanted to write a test case which can show me that when one single code base is used and accessed by two or more individuals at the same time then how does it behaves(I basically want to test for concurrancy). I have chosen the code base as a tic-tac-toe game present on this <a href="https://github.com/bekkopen/erlang-tictactoe/tree/master/src">link</a>. <br></p><p>I have changed the code a bit though and have attached the files in this mail.<br></p><p>Now I tried common_test and wrote the following module <code>testing2</code><br></p><p><code>-module(testing2).<br>-include_lib("common_test/include/ct.hrl").<br>%% ====================================================================<br>%% API functions<br>%% ====================================================================<br>-export([all/0, groups/0, init_per_group/2, end_per_group/2]).<br>-export([test1/1,test2/1]).<br>%% ====================================================================<br>%% Internal functions<br>%% ====================================================================<br>all() -> [{group, session}].</code></p><p><code>groups() -> [{session,<br> [],<br> [{group, clients}]},<br> {clients,<br> [parallel, {repeat, 1}],<br> [test1, test2]}].</code></p><p><code>init_per_group(session, Config) -><br> gameserver:start(),<br> Config;<br>init_per_group(_, Config) -><br> Config.</code></p><p><code>end_per_group(session, _Config) -><br> gameclient:stop();<br>end_per_group(_, _Config) -><br> ok.</code></p><p><code><br></code></p><p><code>test1(_Config)-><br> <br>Abhishek=gameclient:login("Abhishek"),<br>Dharun=gameclient:login("Dharun"),<br> <br> <br>gameclient:new_game(Abhishek),<br> <br> timer:sleep(5),<br> <br> gameclient:make_move(Abhishek, a1),<br> timer:sleep(5),<br> gameclient:make_move(Dharun, b2),<br> timer:sleep(5),<br> gameclient:make_move(Abhishek, a2),<br> timer:sleep(5), <br> gameclient:make_move(Dharun, c3),<br> timer:sleep(5),<br> gameclient:make_move(Abhishek, a3).<br></code></p><p><code><br></code></p><p><code><br>test2(_Config)-><br> <br>Abhijeet=gameclient:login("Abhijeet"),<br>Ranjan=gameclient:login("Ranjan"),<br> <br> <br>gameclient:new_game(Abhijeet),<br> timer:sleep(5),<br> <br> gameclient:make_move(Abhijeet, a1),<br> timer:sleep(5),<br> gameclient:make_move(Ranjan, b2),<br> timer:sleep(5),<br> gameclient:make_move(Abhijeet, a2),<br> timer:sleep(5), <br> gameclient:make_move(Ranjan, c3),<br> timer:sleep(5),<br> gameclient:make_move(Abhijeet, a3).</code></p><p><code><br></code></p><p>Now when I see the logs of ct I find the following output:</p><p><strong>for test1()-></strong><br></p><div><em>=== Started at 2017-09-19 16:37:16</em></div><div><br></div><div><em>“Welcome to tictactoe server!”</em></div><div><em>“Welcome to tictactoe server!”</em></div><div><em>“Ready to rumble against Abhishek!”</em></div><div><em>“Ready to rumble against Dharun!”</em></div><div><br><br><em>=== Ended at 2017-09-19 16:37:16</em><br><em>=== successfully completed test case</em><br><em>=== Returned value: {make_move,a3}</em></div><div></div><div><br></div><div><strong>for test2()-></strong></div><p></p><p><em>=== Started at 2017-09-19 16:37:16</em></p><p><br></p><p><em>“Welcome to tictactoe server!”</em></p><p><em>“Welcome to tictactoe server!”</em></p><p><em>“Ready to rumble against Ranjan!”</em></p><p><em>“Ready to rumble against Abhijeet!”</em></p><p><em>“It is not your turn yet!”</em></p><p><em>“It is not your turn yet!”</em></p><p><br><br><em>=== Ended at 2017-09-19 16:37:16</em><br><em>=== successfully completed test case</em><br><em>=== Returned value: {make_move,a3}</em></p><p><br></p><p>But I expected the output of both the games in the logs as I am running them in parallel.<br></p><p>Can anyone suggest me what am I missing and how to go about it?<br></p><p>Thank you.<br></p><p>Best Regards,<br></p><p>Abhishek<br></p><div></div><div></div></body></html>