Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @DataProvider
- public static Object[][] dataOfInkForConstructor() {
- return new Object[][]{
- {1000}, {0}
- };
- }
- //проверяем чернила в конструкторе
- @Test(dataProvider = "dataOfInkForConstructor")
- public void testPenConstructorInt(int i) throws NoSuchFieldException, IllegalAccessException {
- testObj = new Pen(i);
- Field inkField = testObj.getClass().getDeclaredField("inkContainerValue");
- inkField.setAccessible(true);
- Assert.assertEquals(inkField.get(testObj), i);
- }
- @DataProvider
- public static Object[][] dataOfSizeForConstructor() {
- return new Object[][]{
- {2.0}, {0}
- };
- }
- //проверяем размер букв в конструкторе
- @Test(dataProvider = "dataOfSizeForConstructor")
- public void testPenConstructorDouble(double d) throws NoSuchFieldException, IllegalAccessException {
- testObj = new Pen(1000, d);
- Field sizeField = testObj.getClass().getDeclaredField("sizeLetter");
- sizeField.setAccessible(true);
- Assert.assertEquals(sizeField.get(testObj), d);
- }
- @DataProvider
- public static Object[][] dataOfColors() {
- return new Object[][]{
- {"BLUE"}, {"BLACK"}
- };
- }
- //проверяем цвет в конструкторе. БАГ(!)
- @Test(dataProvider = "dataOfColors")
- public void testPenConstructorColor(String s) throws NoSuchFieldException, IllegalAccessException {
- testObj = new Pen(1000, 1.0);
- Field colorField = testObj.getClass().getDeclaredField("color");
- colorField.setAccessible(true);
- Assert.assertEquals(colorField.get(testObj), s);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement