Is there a standard best practice for unit testing code that generates graphics? I work specifically with Java and jUnit, but I think this concept will be applied in other languages.
So far, the best I can think of is to use Mockito to mock an object Graphicsand claim pre-calculated things like (pseudo-code):
assert that graphics.drawString was called with ("abc", 50, 100)
assert that graphics.setBackgroundColor was called with Color.RED
While all of this is good and good, I was wondering if this was the right thing to do, or if there was a more common practice of testing graphic code.
source
share