From my understanding of the question, I don t think you need to have a GUI test tool here.
There s my idea for simple testing :
- Create an instance AttributeColumnGenerator.
- Create an table.
- Add an Item to the table
- call
generateCell
with an columnId and itemId.
- Do the appropriate assert on the Component returned by the method.
Here s a snippet of my idea
First my ColumnGenerator
who only create a Label with the value of the cell.
public class AttributeColumnGenerator implements Table.ColumnGenerator {
public Object generateCell(Table source, Object itemId, Object columnId) {
String textToDisplay = (String)source.getItem(itemId).getItemProperty(columnId).getValue();
return new Label(textToDisplay);
iii
iii
测试方法
@Test
public void attributeColumnGenratortest()
{
AttributeColumnGenerator columnGenerator = new AttributeColumnGenerator();
Table table = new Table();
String columnId = "test";
table.addContainerProperty(columnId, String.class, "");
String itemId = "item1";
Item item = table.addItem(itemId);
item.getItemProperty(columnId).setValue("Value of item1");
Label generateObject = (Label)columnGenerator.generateCell(table, itemId, columnId);
// Assert any properties of the returned Component.
// In this snippet, I only printOut the boolean comparaison.
System.out.println( "Value of item 1".equals(generateObject.getValue()));
iii
也许它不是最佳解决办法,而是发挥作用。
希望能帮助!
问题。