Skip to content

5. Method

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

This framework provides method level annotations to create complex object @CreateObjectMethod and to map @ReadMethod & @WriteMethod to a field.

CreateObjectMethod

To create complex object developer should/can use a static non-parameterized public method to create an object of the class which will be unit tested.

Example

        @CreateObjectMethod
	public static MyClass05 createObject(){
		MyClass05 myClass05 = new MyClass05();
		if(myClass05.ch == 'F'){
			throw new IllegalAccessError();
		}
		return myClass05;
	}

ReadMethod / WriteMethod

In many cases it happen that read(getter)/write(setter) method of field does not comply with JavaBeans standard. So in this framework developer can map field with non-standard read/write method.

Example

        @ReadMethod(fieldName="flag")
	public boolean hasFlag(){
		return flag;
	}


        @WriteMethod(fieldName="flag")
	public void writeFlag(boolean flag) {
		this.flag = flag;
	}
Clone this wiki locally