I wanted to ask if there is a way to trim String data before comparing it with the data in the table. For example, if we have
|MyCompareClass|
|getString? |
|string1 |
And the result of getString() will be "string1 ". I want the comparison to be green and not Expected "string1". I'm looking for a way to do it without modifying the MyCompareClass source code. Any ideas?
You can write a custom string compare operator class:
public class MyCustomCompare: CellOperator, CompareOperator<Cell> {
public bool CanCompare(TypedValue actual, Tree<Cell> expected) {
return actual.Type == typeof(string);
}
public bool Compare(TypedValue actual, Tree<Cell> expected) {
return actual.Value.ToString().Trim() == expected.Value.Text;
}
}
Then register your class with the Fitnesse
configure fixture:
|configure|processor|add operator|MyCustomCompare|
You could put !-string1 -!
in your cell. All other options I can think of involve code changes to either SUT or fixture.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.