ProductTest.java 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. import static org.junit.Assert.*;
  2. import org.junit.After;
  3. import org.junit.Before;
  4. import org.junit.Test;
  5. /**
  6. * The test class ProductTest.
  7. *
  8. * @author (your name)
  9. * @version (a version number or a date)
  10. */
  11. public class ProductTest
  12. {
  13. /**
  14. * Default constructor for test class ProductTest
  15. */
  16. @Test
  17. public void testEmptyConstructor()
  18. {
  19. Product product = new Product();
  20. }
  21. /**
  22. * Sets up the test fixture.
  23. *
  24. * Called before every test case method.
  25. */
  26. @Before
  27. public void setUp()
  28. {
  29. }
  30. /**
  31. * Tears down the test fixture.
  32. *
  33. * Called after every test case method.
  34. */
  35. @After
  36. public void tearDown()
  37. {
  38. }
  39. @Test
  40. public void testConsWithIdPriceQuantity(){
  41. int id = 19;
  42. double price = 12.00;
  43. int quantity = 7;
  44. Product newProduct = new Product(price, id, quantity);
  45. }
  46. @Test
  47. public void testGetSetPrice(){
  48. Product product = new Product();
  49. double price = 89.99;
  50. product.setPrice(price);
  51. double actualPrice = product.getPrice();
  52. assertEquals(price, actualPrice, 0.01);
  53. }
  54. @Test
  55. public void testGetSetID(){
  56. Product product = new Product();
  57. int ID = 101;
  58. product.setId(ID);
  59. int actualID = product.getId();
  60. assertEquals(ID, actualID);
  61. }
  62. @Test
  63. public void testGetSetQuantity(){
  64. Product product = new Product();
  65. int Quantity = 5;
  66. product.setQuantity(Quantity);
  67. int actualQuantity = product.getQuantity();
  68. assertEquals(Quantity, actualQuantity);
  69. }
  70. }