I am new to JUnit and selenium server so any help is appreciated.
I am running ubuntu 12 with java 7 and selenium ide and server. I created a simple login test script with selenium IDE, and exported it to Java/Junit4/webdriver.
I then compiled that script using the following command
javac -cp .:/usr/share/java/junit4.jar -cp .:/home/sakamoto/SeleniumServer/selenium-server-standalone-2.28.0.jar LoginTest.java
This seemed to go through without any errors (or any messages to the terminal for that matter).
I am seeing this error when trying to run the unit test that was generated from selenium ide exporting to JUnit4 webdriver:
java -cp /home/sakamoto/SeleniumServer/selenium-server-standalone-2.28.0.jar org.junit.runner.JUnitCore com.example.tests.LoginTest
JUnit version 4.11
Could not find class: com.example.tests.LoginTest
Time: 0.001
OK (0 tests)
sakamoto@ubuntu:~/Workspace$
I also have the following lines at the end of my .bashrc file and was able to run the sample test with junit4.
export CLASSPATH=.:/usr/share/java/junit4.jar
export CLASSPATH=.:/usr/share/java/junit.jar
So … How do I get rid of the Could not find class: problem and run the script?
It seems that junit cannot find your LoginTest.class file on the classpath.
Assuming you have a directory structure like this:
Then, try explicitly including the path to the
my-projectdirectory inside the classpath. For example, try this:I think that junit is uses classpath+package name to determine the location of LoginTest test. I’m guessing/hoping that junit will 1) find
/home/sakamoto/my-projectis in the classpath and it will 2) append the package directorycom/examples/testsso that it looks for LoginTest.class inside/home/sakamoto/my-project/com/examples/tests.It’s been a while since I used selenium and, unfortunately, I don’t have selenium set up or I’d test this! But hope that works.