...
To use the degenerate test helper:
References/Links
For repetitive testing of degenerate use of methods with null and empty values, a class DegenerateUseMethodTestHelper is provided, which includes two static methods
- DegenerateUseMethodTestHelper(Object, Method, Parameters, ExpectedFailures)
- DegenerateUseMethodTestHelper(Object, Method, Parameters)
where:
- Object: The service client undergoing testing
- Method: The method of the service client to be tested
- Parameters: An object array of values that that produce successful invocation of the method
- ExpectedFailures: An ExpectedFailure array specifying the degenerate behavior for each parameter.
- EXCEPTION,
- SKIP,
- NONE,
- LONG_INVALID_NO_RESULTS_NULL_EXCEPTION,
- STRING_EMPTY_EXCEPTION_NULL_EXCEPTION,
- STRING_EMPTY_EXCEPTION_NULL_NO_RESULTS,
- STRING_EMPTY_EXCEPTION_NULL_SUCCESS,
- STRING_EMPTY_NO_RESULTS_NULL_EXCEPTION,
- STRING_EMPTY_NO_RESULTS_NULL_NO_RESULTS,
- STRING_EMPTY_NO_RESULTS_NULL_SUCCESS,
- STRING_EMPTY_SUCCESS_NULL_EXCEPTION,
- STRING_EMPTY_SUCCESS_NULL_NO_RESULTS,
- STRING_EMPTY_SUCCESS_NULL_SUCCESS,
- NO_RESULTS,
Example:
Code Block |
---|
SecurityClientRest service = new SecurityClientRest(ConfigUtility.getConfigProperties());
// use reflection to get the desired method
Method method =
service.getClass().getMethod(
"authenticate", // method name and parameters
new Class<?>[] {String.class, String.class}); // i.e. SecurityClientRest.authenticate(String username, String password)
// specify the valid parameters
Object[] parameters = new Object[] {
new String("name"), new String("password") // valid parameters that when passed to method produce successful outcome (e.g. authentication)
};
// call the helper
DegenerateUseMethodTestHelper.testDegenerateArguments(service, method,
parameters); |
References/Links
...