### Question:
ClassUtils { static Field getField(Class<?> targetClass, String fieldName) { while (targetClass != null) { try { Field field = targetClass.getDeclaredField(fieldName); logger.debug("Found field {} in class {}", fieldName, targetClass.getName()); return field; } catch (NoSuchFieldException e) { logger.debug("Failed to find field {} in class {}", fieldName, targetClass.getName()); } targetClass = targetClass.getSuperclass(); } return null; } private  ClassUtils();   }### Answer:
@Test public void testGetField() { Field field = ClassUtils.getField(TestBean.class, "intField"); Assert.assertEquals(field.getType(), int.class); }
@Test public void testGetNonExistingField() { Field field = ClassUtils.getField(TestBean.class, "nonExistingField"); Assert.assertEquals(field, null); }
@Test public void testGetInhertiedField() { Field field = ClassUtils.getField(InheritedTestBean.class, "intField"); Assert.assertEquals(field.getType(), int.class); }