org.junit.runners.model.FrameworkField Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of junit-dep Show documentation
Show all versions of junit-dep Show documentation
JUnit is a regression testing framework written by Erich Gamma and Kent Beck.
It is used by the developer who implements unit tests in Java.
package org.junit.runners.model;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import org.junit.runners.BlockJUnit4ClassRunner;
/**
* Represents a field on a test class (currently used only for Rules in
* {@link BlockJUnit4ClassRunner}, but custom runners can make other uses)
*/
public class FrameworkField extends FrameworkMember {
private final Field fField;
FrameworkField(Field field) {
fField= field;
}
@Override
public Annotation[] getAnnotations() {
return fField.getAnnotations();
}
@Override
public boolean isShadowedBy(FrameworkField otherMember) {
return otherMember.getField().getName().equals(getField().getName());
}
/**
* @return the underlying java Field
*/
public Field getField() {
return fField;
}
/**
* Attempts to retrieve the value of this field on {@code target}
*/
public Object get(Object target) throws IllegalArgumentException, IllegalAccessException {
return fField.get(target);
}
}