12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- import static org.junit.Assert.*;
- import org.junit.After;
- import org.junit.Before;
- import org.junit.Test;
-
- /**
- * The test class ProductTest.
- */
- public class ProductTest
- {
- Product product = new Product("orange",1.50,"12346",400);
- @Test
- public void testSetGetName()
- {
- //Given
- product.setName("Apple");
- //Actual
- String actual = product.getName();
- //Expected
- String expected = "Apple";
- //Test
- assertEquals(expected,actual);
- }
- @Test
- public void testSetGetPrice()
- {
- //Given
- product.setPrice(1.99);
- //Actual
- double actual = product.getPrice();
- //Expected
- double expected = 1.99;
- //Test
- assertEquals(expected,actual,.01);
- }
- @Test
- public void testSetGetID()
- {
- //Given
- product.setID("12345");
- //Actual
- String actual = product.getID();
- //Expected
- String expected = "12345";
- //Test
- assertEquals(expected,actual);
- }
- @Test
- public void testSetGetQuantity()
- {
- //Given
- product.setQuantity(500);
- //Actual
- int actual = product.getQuantity();
- //Expected
- int expected = 500;
- //Test
- assertEquals(expected,actual);
- }
- }
|