...
- Test invalid sort field (specified by string "-")
- Test invalid start index (specified by integer -5);
- Test invalid query restriction (specified by string "BAD_SYNTAX*:*!~bad")
Example:
Code Block |
---|
// the class for which methods are to be tested, in this case SecurityClientRest
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)
};
// if all invalid and null parameters should throw exceptions, use this call
DegenerateUseMethodTestHelper.testDegenerateArguments(service, method,
parameters);
// if different parameters cause different behavior, use this type of call
DegenerateUseMethodTestHelper.testDegenerateArguments(service, method,
parameters, new ExpectedFailure[] {
ExpectedFailure.STRING_INVALID_NO_RESULTS_NULL_EXCEPTION, // an INVALID string will result in no result, a NULL string will result in exception
ExpectedFailure.EXCEPTION // both INVALID strings and NULL strings will result in exception
});
// if specific invalid values are desired, use this type of call
DegenerateUseMethodTestHelper.testDegenerateArguments(service, method,
parameters, new Object[] {
new String("Invalid value"), // the first argument should test "Invalid value", and the method should throw an exception
null // no invalid value will be tested
}); |
...