mercredi 8 juillet 2015

How to test a variable is lazy loaded if private?

I am using JPA and am lazy loading a variable. Were using method level annotations, with the variables all private.

In my automated tests I want to verify that the variable in question is not loaded until I make a call on it. I have found references to using PersistenceUnitUtil.isLoaded method, but I can't pass it the variable directly since it's private.

I tried using my getter method to fetch the lazy loaded variable to pass to PersistenceUnitUtil, but that appears to case it to be loaded which defeats the point of the test.

Is there another way to verify that this private method was not loaded? I suppose I could use reflection to peak at the private variable but that seems pretty convoluted, there must be an easier approach.

If relevant were using spring boot and testNG.

Aucun commentaire:

Enregistrer un commentaire