Demo Test Java
Demo Test Java
Université du Minnesota
Your task is to create a file, DemoTest.java, which properly tests the Demo
class to ensure it is working properly. The correct Demo.java file is
provided for your use.
### Deliverable
Your deliverable is the `DemoTest.java` which tests the Demo class.
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
/**
* The class containing your tests for the {@link
Demo} class. Make sure you
* test all methods in this class (including both
* {@link Demo#main(String[])} and
* {@link Demo#isTriangle(double, double, double)}).
*/
public class DemoTest {
@Test
public void test_is_triangle_1() {
assertTrue(Demo.isTriangle(3,4,5));
}
@Test
public void test_is_triangle_2() {
assertTrue(Demo.isTriangle(5,12,13));
}
@Test
public void test_is_triangle_3() {
assertTrue(Demo.isTriangle(5, 13, 12));
}
@Test
public void test_is_triangle_4() {
assertTrue(Demo.isTriangle(12, 5, 13));
}
@Test
public void test_is_triangle_5() {
assertTrue(Demo.isTriangle(12, 13, 5));
}
@Test
public void test_is_NOT_triangle_1() {
assertFalse(Demo.isTriangle(5,7, 13));
}
@Test
public void test_is_NOT_triangle_2() {
assertFalse(Demo.isTriangle(5,13,7));
}
@Test
public void test_is_NoT_triangle_3() {
assertFalse(Demo.isTriangle(1,2,-1));
}
@Test
public void test_main_program_1() {
ByteArrayInputStream in =
new ByteArrayInputStream("5\n12\n13\
n".getBytes());
System.setIn(in);
ByteArrayOutputStream out = new
ByteArrayOutputStream();
System.setOut(new PrintStream(out));
assertEquals(consoleOutput, out.toString());