I am having a weird problem where I'm just trying to call a method from another class and test the output from the method. Here is java file I am testing:
public class Vehicles {
//Create public Vehicles method here
public Vehicles(){
System.out.println("We have a new vehicle!!");
}
}
Here is the Test Case
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.junit.contrib.java.lang.system.StandardOutputStreamLog;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
@RunWith(JUnit4.class)
public class Testsuite{
@Rule
public final StandardOutputStreamLog out = new StandardOutputStreamLog();
@Test
public void main(){
Vehicles.Vehicles();
assertThat(out.getLog(), containsString("We have a new vehicle!!"));
}
}
I get the following error:
Testsuite.java:22: error: cannot find symbol Vehicles.Vehicles(); ^ symbol:
method Vehicles() location: class Vehicles 1 error
I know that it can't find the Vehicles.Vehicles();
I just don't know why it can't. I checked my spelling and everything so I'm just lost. I'm new to JUnit and Unit testing in general so any help will be greatly appreciated. Thanks in advance to everyone for the help.
Aucun commentaire:
Enregistrer un commentaire