Advertisement
Guest User

Untitled

a guest
Apr 30th, 2017
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.76 KB | None | 0 0
  1.     @DataProvider
  2.     public static Object[][] dataOfInkForConstructor() {
  3.         return new Object[][]{
  4.                 {1000}, {0}
  5.         };
  6.     }
  7.     //проверяем чернила в конструкторе
  8.     @Test(dataProvider = "dataOfInkForConstructor")
  9.     public void testPenConstructorInt(int i) throws NoSuchFieldException, IllegalAccessException {
  10.         testObj = new Pen(i);
  11.         Field inkField = testObj.getClass().getDeclaredField("inkContainerValue");
  12.         inkField.setAccessible(true);
  13.         Assert.assertEquals(inkField.get(testObj), i);
  14.     }
  15.     @DataProvider
  16.     public static Object[][] dataOfSizeForConstructor() {
  17.         return new Object[][]{
  18.                 {2.0}, {0}
  19.         };
  20.     }
  21.     //проверяем размер букв в конструкторе
  22.     @Test(dataProvider = "dataOfSizeForConstructor")
  23.     public void testPenConstructorDouble(double d) throws NoSuchFieldException, IllegalAccessException {
  24.         testObj = new Pen(1000, d);
  25.         Field sizeField = testObj.getClass().getDeclaredField("sizeLetter");
  26.         sizeField.setAccessible(true);
  27.         Assert.assertEquals(sizeField.get(testObj), d);
  28.     }
  29.     @DataProvider
  30.     public static Object[][] dataOfColors() {
  31.         return new Object[][]{
  32.                 {"BLUE"}, {"BLACK"}
  33.         };
  34.     }
  35.  
  36.     //проверяем цвет в конструкторе. БАГ(!)
  37.     @Test(dataProvider = "dataOfColors")
  38.     public void testPenConstructorColor(String s) throws NoSuchFieldException, IllegalAccessException {
  39.         testObj = new Pen(1000, 1.0);
  40.         Field colorField = testObj.getClass().getDeclaredField("color");
  41.         colorField.setAccessible(true);
  42.         Assert.assertEquals(colorField.get(testObj), s);
  43.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement