123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- import static org.junit.Assert.*;
- import org.junit.After;
- import org.junit.Before;
- import org.junit.Test;
-
- /**
- * The test class ProductTest.
- *
- * @author (your name)
- * @version (a version number or a date)
- */
- public class ProductTest{
- @Test
- public void testEmptyConstructor(){
- Product product = new Product();
- }
-
- @Test
- public void testConstructorWithIdpriceQuantity(){
- String id = "5349h8te";
- double price = 55.55;
- int quantity = 3;
-
- Product newProduct = new Product(id, price, quantity);
- }
-
- @Test
- public void testGetSetPrice(){
- Product product = new Product();
- double price = 88.67;
-
- product.setPrice(price);
- double actualPrice = product.getPrice();
-
- assertEquals(price, actualPrice, 0.01);
- }
-
- @Test
- public void testGetProductId(){
- Product product = new Product();
- String id = "867_XX";
-
- product.setId(id);
- String actualId = product.getId();
-
- assertEquals(id, actualId);
- }
-
- @Test
- public void testGetQuantityNumber(){
- Product product = new Product();
- int quantity = 12;
-
- product.setQuantityOfItem(quantity);
- int actualQuantity = product.getQuantityOfItem();
-
- assertEquals(quantity, actualQuantity);
- }
- }
|