java - Testing graphics generation with JUnit -


I am using Graphics 2D of Java to generate graphical representation of the article. I am using ImageIO to write a PNG file. ( ImageIO.write (image, "png", out); )

I'm thinking how to write a JUnate test, to check whether the generated graphics is expected is. I can pre-PNG files, but what if the font is different on a different machine?

You can try testing specific, known attributes of the output such as:

  • Is there a white pixel on (100,100)?
  • Is this limit completely black?
  • Is the image expected size?

And / or you can write a test for some "total assets" which allow some fidget in the result:

  • Get less than 90% of the match from the image?
  • Is the most common color in the image equal to the background color?

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -