Talar97

[PIO] Testy jednostkowe

Jan 30th, 2019
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.20 KB | None | 0 0
  1. package com.Talar;
  2.  
  3. import org.junit.Before;
  4. import org.junit.Test;
  5.  
  6. import static org.junit.Assert.*;
  7.  
  8. public class ItemTest {
  9.     Item it;
  10.  
  11.     @Before
  12.     public void setUp(){
  13.         it = new Item("Japko", 5);
  14.     }
  15.  
  16.     @Test
  17.     public void getNazwa() throws Exception {
  18.         assertEquals(it.getNazwa(), "Japko");
  19.     }
  20.  
  21.     @Test(expected = IllegalArgumentException.class)
  22.     public void setZlaNazwa() throws Exception {
  23.         it.setNazwa("Japko55");
  24.     }
  25.  
  26.     @Test(expected = IllegalArgumentException.class)
  27.     public void setZaKrotkaNazwa() throws Exception {
  28.         it.setNazwa("a");
  29.     }
  30.  
  31.     @Test(expected = IllegalArgumentException.class)
  32.     public void setNullNazwa() throws Exception {
  33.         it.setNazwa(null);
  34.     }
  35.  
  36.     @Test
  37.     public void setPoprawnaNazwa() throws Exception{
  38.         it.setNazwa("Jabko");
  39.     }
  40.  
  41.     @Test
  42.     public void getCena() throws Exception {
  43.         assertEquals(it.getCena(), 5);
  44.     }
  45.  
  46.     @Test(expected = IllegalArgumentException.class)
  47.     public void setUjemnaCena() throws Exception {
  48.         it.setCena(-5);
  49.     }
  50.  
  51.     @Test
  52.     public void setCena() throws Exception {
  53.         it.setCena(5);
  54.     }
  55.  
  56. }
Add Comment
Please, Sign In to add comment