Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+21 votes

I was creating unit tests to test methods in the LessonPlan class and I was getting this error "java.lang.RuntimeException: Internal graphics not initialized yet". The error pointed to a data field in the Card class which is type Image. How do I get around this error while unit testing?

asked in CSC305 Fall 2023 by (1 point)

1 Answer

+7 votes

Try calling Platform.startup() before your test. (Or better, in a @BeforeAll init method in your unit test class.

If that fails, maybe you'll need another approach here:

https://stackoverflow.com/questions/39582837/internal-graphics-not-initialized-yet-in-juunit-test-case

answered by (3.8k points)
+2

Putting

Platform.startup(()->{});

at the top of the method made it work!

...