ProductTest.java 914B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import org.junit.Before;
  2. import static org.junit.Assert.*;
  3. import org.junit.Test;
  4. /**
  5. * Created by leon on 1/10/18.
  6. */
  7. public class ProductTest {
  8. private Product product;
  9. @Before
  10. public void setup(){
  11. product = new Product();
  12. }
  13. @Test
  14. public void setNameTest(){
  15. product.setName("lemon");
  16. String name = "lemon";
  17. assertEquals(product.getName(),name);
  18. }
  19. @Test
  20. public void setPriceTest(){
  21. product.setPrice(5.00);
  22. double price = 5.00;
  23. assertEquals(product.getPrice(),price,1E-8);
  24. }
  25. @Test
  26. public void setIDTest(){
  27. int id = 570370;
  28. product.setID(570370);
  29. assertEquals(product.getID(),id);
  30. }
  31. @Test
  32. public void setQuantityTest(){
  33. int quantity = 30;
  34. product.setQuantity(30);
  35. assertEquals(product.getQuantity(),quantity);
  36. }
  37. }