Posted By

vinocui on 11/25/10


Tagged

batch dos junit selenium


Versions (?)

Batch file to compile and run Selenium RC test scripts (JUnit based)


 / Published in: DOS Batch
 

Simply specify your test class name in SOURCE variable.

  1. @IF "%1" == "/?" GOTO HELP
  2. @IF "%1" == "/clean" GOTO CLEAN
  3.  
  4. @SET SOURCE=TestCreate
  5. @SET JUNIT=junit-4.0.jar
  6. @SET DRIVER=selenium-java-client-driver.jar
  7. @SET RUNNER=org.junit.runner.JUnitCore
  8.  
  9. @FOR %%i IN (%SOURCE%) DO @IF EXIST %%i.class ( @ECHO %%i.class found. ) ELSE ( @echo Compiling %%i.java ... && @javac -cp .;%CD%\selenium-java-client-driver.jar;%CD%\junit-4.0.jar %%i.java || @IF errorlevel 1 GOTO COMPILE_ERR)
  10.  
  11. @ECHO Connecting to Selenium core server to test TestCreate
  12. @java -cp .;%CD%\%JUNIT%;%CD%\%DRIVER% %RUNNER% TestCreate
  13. @GOTO END
  14.  
  15.  
  16. :COMPILE_ERR
  17. @ECHO Error encounted during compiling.
  18. @GOTO END
  19.  
  20. :MEM
  21. @rem @FOR %%i IN (%SOURCE%) DO @IF EXIST %%i.java ( @echo %%i ) ELSE ( @echo %%i missing. )
  22. @ECHO Compiling TestCreate.java
  23. @javac -cp .;e:\code\java\selenium-java-client-driver.jar;e:\code\java\junit-4.0.jar TestCreate.java
  24. @rem @FOR %%i IN (%SOURCE%) DO @echo Compiling %%i.java ... && @javac -cp .;%CD%\selenium-java-client-driver.jar;%CD%\junit-4.0.jar %%i.java || @IF errorlevel 1 GOTO COMPILE_ERR
  25. @GOTO END
  26.  
  27. :HELP
  28. @ECHO Options:
  29. @ECHO Use /clean to clean *.class
  30. @GOTO END
  31.  
  32. :CLEAN
  33. @DEL /F /Q *.class
  34. @GOTO END
  35.  
  36. :END

Report this snippet  

You need to login to post a comment.