Turns cell text into the declared type with a converter
All 5 scenarios hold
A static @TypeConverter method in the test class decides what a cell's text becomes. A table can then use the language of the domain, in place of programmer literals.
Three converters serve the tables below. Yes/No becomes a boolean. A number word becomes an integer. A day word becomes a date.
Each rule below keeps the conversion visible. Each table pairs the text of the cell with the value the test method receives, printed back as plain text. That column is a String, and no converter touches a String. The column therefore shows what the converter produced, and does not restate what the converter was given.
Yes and No become booleans, for a primitive and a boxed parameter alike.
A converter does not extend the built-in conversion of its type. It replaces it. Read the last row before you add a converter for a common type. A cell written true arrives as false, because this converter recognises yes and nothing else. The built-in conversion that would have read true never runs.
| Scenario | boolean | Boolean | Converted value as text? |
|---|---|---|---|
| Affirmative | Yes | Yes | true |
| Negative | No | No | false |
| Case is ignored | yES | yES | true |
| Unrecognised word | maybe | maybe | false |
| The built-in spelling | true | true | false |