Perl unit test - start a tcp server & continue

Posted by John on Stack Overflow See other posts from Stack Overflow or by John
Published on 2010-04-16T01:15:15Z Indexed on 2010/04/16 1:23 UTC
Read the original article Hit count: 285

Filed under:
|
|

I am trying to write a unit test for a client server application. To test the client, in my unit test, I want to first start my tcp server (which itself is another perl file). I tried to start the tcp server by forking:

if (! fork()) {
    system ("$^X server.pl") == 0 or die "couldn't start server"
}

So when I call "make test" after "perl Makefile.PL", this test starts & I can see the server starting but after that the unit test just hangs there. So I guess I need to start this server in background and I tried the "&" at the end to force it to start in background & then test to continue. But, I still couldn't succeed. What am I doing wrong? Thanks.

© Stack Overflow or respective owner

Related posts about perl

Related posts about unit-testing