posted 4 years ago
Good morning Ranchers,
I'm writing some tests and need to make some assertions based on values given during setup. Normally the setup and assertion hook methods live in the same class so is trivial to store data between them using local fields. However, in this case the setup and assertion methods live in different classes. For example:
Please put to one side the silliness of my example, I have simplified it from reality to the point where it looks ridiculous (doesn't even compile) but does demonstrate the key problem which is how to share the dataStore between classes.
I know that I could take a Map instance and wrap it up in a singleton, but I feel this is a problem that's likely already been solved so am looking for an 'off the shelf' solution. Perhaps Spring, or Guava, or Apache, or something else has a ready made solution?
Does anyone know of something like this?
Cheers, Tim