Return to Snippet

Revision: 36757
at November 25, 2010 23:04 by vinocui


Initial Code
@IF "%1" == "/?" GOTO HELP
@IF "%1" == "/clean" GOTO CLEAN

@SET SOURCE=TestCreate
@SET JUNIT=junit-4.0.jar
@SET DRIVER=selenium-java-client-driver.jar
@SET RUNNER=org.junit.runner.JUnitCore

@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)

@ECHO Connecting to Selenium core server to test TestCreate
@java -cp .;%CD%\%JUNIT%;%CD%\%DRIVER% %RUNNER% TestCreate
@GOTO END


:COMPILE_ERR
@ECHO Error encounted during compiling.
@GOTO END

:MEM
@rem @FOR %%i IN (%SOURCE%) DO @IF EXIST %%i.java (        @echo %%i    ) ELSE (        @echo %%i missing.    )
@ECHO Compiling TestCreate.java
@javac -cp .;e:\code\java\selenium-java-client-driver.jar;e:\code\java\junit-4.0.jar TestCreate.java
@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
@GOTO END

:HELP
@ECHO Options:
@ECHO Use /clean to clean *.class
@GOTO END

:CLEAN
@DEL /F /Q *.class
@GOTO END

:END

Initial URL

                                

Initial Description
Simply specify your test class name in SOURCE variable.

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

Initial Tags

                                

Initial Language
DOS Batch