You are on page 1of 2

package testcases;

import static org.junit.Assert.*;


import java.util.ArrayList;
import metode.Scaun;
import metode.Utile;
import org.junit.Test;
public class TestUtile {
@Test
public void test() {
Utile obiect=new Utile();
int rezultat=obiect.suma(3, 7);
assertEquals(10, rezultat);
}
@Test
public void testRaport() {
Utile obiect=new Utile();
double rezultat=obiect.raport(25, 6);
assertEquals(4.163, rezultat, 0.3);
}
@Test
public void testRaport_fail() {
Utile obiect=new Utile();
double rezultat=0;
try{
rezultat=obiect.raport(5, 0);
System.out.println(rezultat);
fail("Trebuie sa fie exceptie");
}
catch(Exception ert){
System.out.println(rezultat);
}
}
@Test
public void testRaport_fail2() {
Utile obiect=new Utile();
double rezultat=0;
try{
rezultat=obiect.raport(9, 0);
fail("nu trebuia sa ajunga aici");
}
catch(Exception ert){
System.out.println(rezultat);
}
}
@Test
public void testEsteNrPar() {

Utile obiect=new Utile();


boolean rezultat=obiect.estePar(6);
assertTrue(rezultat);
}
@Test
public void testLista() {
Utile obiect=new Utile();
ArrayList<String> lista=obiect.creareLista("Elena", "Maria");
assertNull(lista);
}
@Test
public void testListaNOTNULL() {
Utile obiect=new Utile();
ArrayList<String> lista=obiect.creareLista("Elena merge la produ
s", "Maria taie bon");
assertNotNull(lista);
}
@Test
public void testScaun() {
Scaun s=new Scaun(5);
Scaun d=s.returneaza(s, 6);
assertSame(d, s);
}

You might also like