Assume that we have some simple Java visual component, for example, rectangle. Component can change position (let it be changePosition(int x, int y) method) and color (changeColor(Color color)). How can I create unit -test for such component?
This is extremely simple situation, but, I think, it is nice illustration for my question: how we can create unit-test for any visual component in Java?
Thanks in advance
I strongly doubt, that a component can change its position or change its color. Components have properties that are used by rendering engines to display them on a screen.
A visual component is some sort of model for something that we see on a display.
So when we call
changePosition(x,y)on a component, then we usually alter field values on the component instance. And we only have to (unit-)test, if those fields have the expected values after we calledchangePosition(x,y).