Answer the question
In order to leave comments, you need to log in
Service testing, is it possible to create a separate class to store test objects or is it bad practice?
This is new for me.
When testing the service, the idea arose to create a separate TestData class and throw all objects and collections there (but make them unmodifiable, and objects final ). It's like an alternative to destroying and creating objects in @BeforeEach in the service test class. All the same, these objects do not change anywhere in the service.
Is it good practice to do this?
Or do you need to specifically prescribe objects in the class and re-create each time?
I will be very grateful to you for the answer.
Answer the question
In order to leave comments, you need to log in
Could be so.
I've seen some guys write DSL for testing purposes. (Like: User user = ObjectFather.getDefaultUser().with ... .please())
Well, I prefer storing test data as jasons: jasons are easy to store, easy to view, easy to convert to an object.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question