[Webtest] [Developers] New API for com.canoo.webtest.steps.Step

Denis N. Antonioli webtest@lists.canoo.com
Mon, 7 Nov 2005 15:30:28 +0100


Hi

Since build R_1015, the interface of Step has been simplified as  
discussed this since spring on the mailing list:

a Context is given to a Step with the method setContext(Context) and  
it doesn't need to be passed to other methods.
All methods of Step that have a Context as a parameter have been  
deprecated.


=============
The deprecated method will be removed after the release of the final  
version of webtest 1.7.
=============



For most steps, the necessary changes are very simple:

(1) change from:
	doExecute(final Context context) {
		// perform the step's functionality
	}
to
	doExecute() {
		final Context context = getContext();
		// perform the step's functionality
	}

(2) change from:
	protected void verifyParameters(final Context context) {
		super.verifyParameters(context);
		// verify here the step's parameters
	}
to
	protected void verifyParameters() {
		super.verifyParameters();
		final Context context = getContext();
		// verify here the step's parameters
	}


For the special cases of step calling other steps, The test method  
BaseStepTestCase#executeStep documents the minimal calling sequence  
to correctly execute a Step.
It is:

		step.setContext(context);
		step.expandProperties();
		step.verifyParameters();
		step.doExecute();

Note that means that the doExecute() method doesn't need to call  
expandProperties() or verifyParameters() on itself, it is the  
responsibility of the caller to do so.


Happy testing
	dna

-- 
in a flash of inspiration she had discovered the comic possibilities  
of the semi-colon, and of this she had made abundant and exquisite use.
   -- W. Somerset Maugham, The creative impulse