5

On a Windows 7 machine if I run a PHPUnit Selenium command like this manually in the terminal:

phpunit --verbose --log-junit _selenium_tests\results\home.xml _selenium_tests\frontend\home.php

It spawns a browser and runs the test just fine. Then it outputs the following on the screen:

Time: 10 seconds, Memory: 3.50Mb
OK (1 test, 3 assertions)

And the terminal stays open.

Now if I copy and paste the exact command in an empty file and save it as test.bat and click it, it also runs the test. I can see the browser open and all tests run. Only problem is it closes the terminal prompt right after. So I can't see the above output.

An even bigger problem is, since it closes the terminal if I add more commands for other tests after that initial one they don't run.

I tried adding:

pause

at the end of the bat file but no luck, it still closes. Any idea how to prevent this and be able to run one command after another without the terminal ever closing?

2 Answers 2

11

Your question is similar to this one. Try using call in front of your command. If you run a .bat file from another .bat file and don't use call, control doesn't return to the first batch file, so pause doesn't get executed.

1
  • dude you're awesome, simply putting call before all the commands did it. Now they all ran one after another and the terminal never closed. Thanks!
    – user967451
    Jul 23, 2012 at 15:31
0
  • Try cmd /K phpunit --verbose --log-junit _selenium_tests\results\home.xml _selenium_tests\frontend\home.php

    The /K option in cmd /K string Carries out the command specified by string but remains,
    see http://www.computerhope.com/cmd.htm

  • Also, I don't know the file type of the phpunit command you execute - I'm not familiar with selenium. If it is batch file (i.e. ends with .bat), you just can't call them from another batch file: everything below the call to the second batch file will never get executed.

    You then need to use the CALL command. CALL Enables a user to execute a batch file from within another batch file,
    see http://www.computerhope.com/call.htm

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.