Skip to content

4. Fields

Anindya Bandopadhyay edited this page Jan 24, 2018 · 2 revisions

This framework provides field-level annotations to ignore and test with custom values of primitive & String fields.

  • Field mark with @IgnoreField annotation will be ignored from testing.
  • @BooleanTestValue, @ByteTestValue, @CharTestValue, @DoubleTestValue, @FloatTestValue, @IntTestValue, @LongTestValue, @ShortTestValue and @StringTestValue annotations can be used with the respective data type to pass custom values for testing. These annotations have two attributes assignValues and expectedValues, where assignValues is what values will be written to a field using write/setter method and expectedValues what values are expected in unit testing.

Illustration

public class Test03 {

	@IgnoreField
	private int num1; // Will be ignored

	@StringTestValue(assignValues={"Andy"},expectedValues = {"ANDY"})
	private String str; // may be getter method return an upper case string

	private boolean flag;
}
Clone this wiki locally