In my programming class, we are trying to figure out an assignment that was given to us to JUnit test code that we put together. And we are running into an issue because we can't tell if the void method is outputting the string inside correctly. Is there a way to test that? Or is that not legal in the Java language?
Side Note: The void method is an interface (we were learning about interfaces and polymorphism).
Some code to get the idea-
Creation of the interface:
public interface Flyable {
/**
* Method: Launch - void
*/
void launch();
/**
* Method: Land - void
*/
void land();
The class we're wanting to test(In the class Plane):
@Override
public void launch() {
System.out.println("Rolling until take-off");
}
@Override
public void land() {
System.out.println("Rolling to a stop");
}
The test we're trying to figure out:
/**
* Method: Test Method for test Launch
*/
@Test
void testLaunch() {
assertEquals("Rolling until take-off", myPlane.launch());
}
/**
* Method: Test Method for test Land
*/
@Test
void testLand() {
assertEquals("Rolling to a stop", myPlane.land());
}
Is there any way we can get something like this to work? Hope this made sense!