Files
mvnAction/src/test/java/PrepSession/FishTestCase.java
T
Sami 89a159224e
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 6s
Gitea Actions Demo / GoBuild (push) Failing after 4s
Fix: 1
2024-09-09 17:58:15 -04:00

32 lines
1.1 KiB
Java

package PrepSession;
import org.junit.Test;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import static org.junit.Assert.assertEquals;
public class FishTestCase {
// Fish hides successfully
@Test
public void test_fish_hides_successfully() {
Fish fish = new Fish();
// Assuming the output is checked via console output, we can use System.out to capture it.
// This is a simple example, in real scenarios, we might use a logging framework or mock the output.
ByteArrayOutputStream outContent = new ByteArrayOutputStream();
System.setOut(new PrintStream(outContent));
fish.Hiding();
assertEquals("The fish is going deeper to hide from the Eagle\n", outContent.toString());
}
@Test
public void test_fishAttack(){
Fish fish = new Fish();
ByteArrayOutputStream attckOut = new ByteArrayOutputStream();
System.setOut(new PrintStream(attckOut));
fish.Attacking();
assertEquals("The fish attacked a smaller fish\n", attckOut.toString());
}
}