import static org.junit.jupiter.api.Assertions.*;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;

import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

class HelloTest {
	
	@Test
	@DisplayName("Test printing of \"Hello World!\"")
	public void testMain(){
		
	    String[] args = null;
	    	    
	    ByteArrayOutputStream baos = new ByteArrayOutputStream();
	    PrintStream ps = new PrintStream(baos);
	    PrintStream old = System.out;
	    System.setOut(ps);
	    Hello.main(args);
	    System.out.flush();
	    System.setOut(old);
	    
	    String output = baos.toString();
	    String expected = "Hello World!";
	   
	    assertNotNull(output, "Tests that there is something printed to the terminal");
	    assertTrue(output.startsWith(expected), "Tests that \"Hello World!\" has printed");
	    
	}

}
