Bash file is running fine in windows for testng bu

2019-01-12 08:31发布

问题:

My bash file is running fine in windows but it is not working in linux/mac. I have created a selenium project with testng and I want to create a bash file so I can run my project without IDE

I have searched but till not getting any solution for same

Error on terminal:-

>bash TestNg_RunMe.bat 
>Error: Could not find or load main class ..src.lib.selenium-java-2.46.0.jar
>TestNg_RunMe.bat: line 1: ./bin: Is a directory

Note:- I have use bash command also to run the command in linux and mac

Also lib and bin directory is present in right place(As it working fine in windows)

My bash file is :-

java -cp ./src/lib/*;./bin org.testng.TestNG testng.xml

Above bash is working perfect for windows I have also tried with full absolute path I have also extract testng.jar and add it in bash file but nothing work.

回答1:

Paths are separated using : under Unix-like systems and not ; as in Windows:

java -cp ./src/lib/*:./bin org.testng.TestNG testng.xml

If you are using bash under Windows then changing to : should work everywhere.

The ; character means end of statement to a Unix shell, so what you are attempting to exceute is:

java -cp ./src/lib/*
./bin org.testng.TestNG testng.xml