开发者

Start Selenium RC server automatically

How can I automatically start and stop the Selenium RC server when I run my phpunit tests?

I thought I could create a little bash script that does something like this (does not work though):

java -jar ~/bin/selenium-server-standalone-2.0b3.jar &
phpunit --configuration suite.xml &&
killall java

Surely there's a way to do that righ开发者_运维知识库t? To make the first line run in the background, and the second block execution until completion.

Or is there another good way of doing this? Does phpunit have a facility for running a process first?

I feel like I need to completely automate this because if I forget to start the server, phpunit doesn't even throw any errors, it just skips the tests!


Are you want to run shell script, java or php code ?

php code : exec("/path to file/script.sh");

java code : Process p = Runtime.getRuntime().exec(/path to file/script.sh);

same for bat file. and that script contains the command launching of selenium server or directly execute the command for launching server. Please be clear about your question and in which language??????


(Just for fun)

TMPFILE=`mktemp` 
SELENIUMJAR=~/bin/selenium-server-standalone-2.0b3.jar

bash  -c  "echo $$ &&       java -jar  '${SELENIUMJAR}'" > "$TMPFILE" &
                            sleep 0.1                             
pid=`head -1 <              "$TMPFILE"`
phpunit   --configuration   suite.xml
kill      "$pid"   ;        sleep   2 
kill -9   "$pid"   ;        sleep 0.1 
rm        "$TMPFILE"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜