-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support mock strategies and type replacement in Spring unit test fuzzing #2561
Conversation
701fb39
to
163e168
Compare
@Markoutte, could you take a look, please? |
1ba7d74
to
b130123
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me it is hard to understand all type hierarchy in Spring module and all those wrappers, delegators and adapters. Maybe, documentation could help?
* arbitrary types, unlike type-specific value providers that were designed to provide values of | ||
* few specific popular types (e.g. `List`, `String`, etc.). | ||
*/ | ||
interface AnyObjectValueProvider : JavaValueProvider |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Marker interface usually doesn't extend any other interfaces and has no methods. This is because you could use several marker interfaces for one class. In this case AnyObjectValueProvider
is used as real type in hierarchy, that maybe useful, but I think it is redundant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not redundant, because it's used in MockingJavaFuzzingContext
, which avoids mocking types that have value providers other than AnyObjectValueProvider
, because it's a bad practice to mock types like List
, Date
, and Map
.
I can't simply list all implementers of AnyObjectValueProvider
in MockingJavaFuzzingContext
, because the set of these implementers is subject to change as #2583 shows.
Made AnyObjectValueProvider
truly a marker interface that doesn't extend any interfaces.
7f325a4
to
98da383
Compare
Description
Makes fuzzing in Spring unit tests respect mock strategy and type replacement:
MockValueProvider
is used if mock strategy allows it and type isn't replaced, otherwiseObjectValueProvider
is used (MockValueProvider
is also used when no other way to create non-null value is found)InjectMockValueProvider
(one that outputs composite models) is only used to createthisInstance
.How to test
Manual tests
Generate unit tests with every mocking strategy (including Spring-specific mocking strategy that uses Spring configuration) for
spring-boot-testing
project.Self-check list