Answer the question
In order to leave comments, you need to log in
Should I rewrite the class for convenient spring rest client testing?
Actually here what dilemma:
Test only public methods.
To access the public api - I have a private method in the class - getting an authorization token. - it is called when calling any public method of accessing the rest.
Test getting a token - I think it's a must. But I also think that making the method for obtaining a token public is superfluous (except for the possibility of a convenient test).
How do you get around such contradictions?
Answer the question
In order to leave comments, you need to log in
If you want to test receiving a token separately (integration testing), then you need to have a separate component. As for testing the component for accessing the API, the answer is checked as a whole. And if there is an authorization error, then the test should fail. This is fine
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question