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


/ Published in: DOS Batch
Save to your folder(s)

Simply specify your test class name in SOURCE variable.


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.