Reputation: 5
I have a Junit Test Project and I have been on your site finding answers on how to get my program to run from a command prompt.
I can supply the code. I added a main method to the code that has the test class. I found an example that has this code in the main method: JUnitCore jCore = new JUnitCore(); jCore.run();
But all that executes is the main method and not the test. All of the other examples I see include the name of the class, bu when I add that to the command above it gives me an error. I think it is because the main method is within the test class. My programs are .java and not .class so I at a lost as to what to do now.
I am not finding anything that shows the complete steps. Should also add that I have not done Java for over 13 years so I am rusty.
Here is the code I tried:
public class Selenium_Email_TestCase {
private WebDriver driver;
private String baseUrl;
private boolean acceptNextAlert = true;
private StringBuffer verificationErrors = new StringBuffer();
public static void main(String[] args) {
System.out.println("In main method");
JUnitCore jCore = new JUnitCore();
jCore.run(Selenium_Email_TestCase);
}
}
Upvotes: 0
Views: 3805
Reputation: 24520
You must use the class object.
jCore.run(Selenium_Email_TestCase.class);
Don't forget to import Selenium_Email_TestCase
if it resides in a different package.
Upvotes: 2