java - Custom FEST Assertions : Displaying readable message with -
i have created custom fest condition verify actual string either matches or equal expected string
public class stringmatchesorisequalto extends condition<string>{ private string expectedstringorexpression; public stringmatchesorisequalto(final string expectedstringorexpression){ this.expectedstringorexpression = expectedstringorexpression; } @override public boolean matches(string value) { return value.matches(expectedstringorexpression) || value.equals(expectedstringorexpression); } } whenever conditon fails want display message shows me original , expected string
currently display string
actual value:<'some string'> should satisfy condition:<stringmatchesorisequalto> is there way message displays match made against ?
i tried overriding tostring method in class
@override public string tostring() { return "string matches or equal : " + expectedstringorexpression; } but not seem work.
you want set description, can done calling condition(string) constructor:
public stringmatchesorisequalto(final string expectedstringorexpression){ super("a string matches, or equal to, '" + expectedstringorexpression "'"); this.expectedstringorexpression = expectedstringorexpression; } alternatively, override description():
@override public string description() { return "a string matches, or equal to, '" + expectedstringorexpression "'"); }
Comments
Post a Comment