import org.junit.* ; import Examples.Triangle; import static org.junit.Assert.* ; public class TestTriangle { Triangle equilateral() { Triangle t = new Triangle() ; t.setA(1) ; t.setB(1); t.setC(1); return t ; } Triangle isoceles() { Triangle t = new Triangle() ; t.setB(3) ; t.setC(3); return t ;} Triangle scalene() { return new Triangle() ; } @Test public void test() { assertTrue(equilateral().isEquilateral()) ; assertTrue(equilateral().isIsoleces()) ; assertFalse(equilateral().isScalene()) ; assertFalse(isoceles().isEquilateral()) ; assertTrue(isoceles().isIsoleces()) ; assertFalse(isoceles().isScalene()) ; assertFalse(scalene().isEquilateral()) ; assertFalse(scalene().isIsoleces()) ; assertTrue(scalene().isScalene()) ; } //@Test public void illegalTriangle_BO() { try { Triangle t = new Triangle() ; t.setA(0) ;assertTrue(false) ; } catch(IllegalArgumentException e) { } try { Triangle t = new Triangle() ; t.setB(0) ;assertTrue(false) ; } catch(IllegalArgumentException e) { } try { Triangle t = new Triangle() ; t.setC(0) ;assertTrue(false) ; } catch(IllegalArgumentException e) { } } }