-
Notifications
You must be signed in to change notification settings - Fork 43
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
Introduce object creation using builders for fuzzers #2583
base: main
Are you sure you want to change the base?
Conversation
utbot-java-fuzzing/src/main/kotlin/org/utbot/fuzzing/providers/Objects.kt
Outdated
Show resolved
Hide resolved
utbot-java-fuzzing/src/main/kotlin/org/utbot/fuzzing/providers/Objects.kt
Outdated
Show resolved
Hide resolved
utbot-java-fuzzing/src/main/kotlin/org/utbot/fuzzing/providers/Objects.kt
Show resolved
Hide resolved
utbot-java-fuzzing/src/main/kotlin/org/utbot/fuzzing/providers/Objects.kt
Show resolved
Hide resolved
utbot-java-fuzzing/src/main/kotlin/org/utbot/fuzzing/providers/Objects.kt
Outdated
Show resolved
Hide resolved
utbot-java-fuzzing/src/main/kotlin/org/utbot/fuzzing/providers/Objects.kt
Outdated
Show resolved
Hide resolved
utbot-java-fuzzing/src/main/kotlin/org/utbot/fuzzing/providers/Objects.kt
Outdated
Show resolved
Hide resolved
utbot-java-fuzzing/src/main/kotlin/org/utbot/fuzzing/providers/Objects.kt
Show resolved
Hide resolved
utbot-java-fuzzing/src/main/kotlin/org/utbot/fuzzing/providers/Objects.kt
Show resolved
Hide resolved
utbot-java-fuzzing/src/main/kotlin/org/utbot/fuzzing/providers/Objects.kt
Show resolved
Hide resolved
utbot-java-fuzzing/src/main/kotlin/org/utbot/fuzzing/providers/Objects.kt
Outdated
Show resolved
Hide resolved
Now it finds bridge method I think the codebase is not ready to deal with arbitrary classes that can be found on the classpath and the best solution for now is to make sure that we only create In other words some The easiest way to achieve that, that I can see is to make
|
@IlyaMuravjov I think that there're a many of other problems that we won't find by this review. Let's create separate issues with reproducers and stack traces for them and fix them. The main goal of this PR is to add this builder for Java, not for Spring. And I'd like to keep Java part as simple as possible without additional wrappers and delegators. |
…iders # Conflicts: # utbot-spring-framework/src/main/kotlin/org/utbot/framework/context/spring/SpringApplicationContextImpl.kt
@Markoutte I merged Also, this PR reveled a problem in instrumnted-process that marks executions as timed out even if the thing that actually timed out is the argument creation prior to method under test invocation, see #2595. Next, it seems that
Meaning that for large projects Finally, I tried to check by how much providing public static boolean isNull(LocalDateTime localDateTime) {
if (localDateTime == null) return true;
return false;
}
|
…ing (#2561) * Support mock strategies and type replacement in Spring unit test fuzzing * Avoid mocking replaced types * Only use `InjectMockValueProvider` for `thisInstance` * Disallow non-mocks when mock can be used * Move all value provider decorators to one package * Improve adding of `ReplacedFuzzedTypeFlag` * Make `map` and `except` apply transformer/filter to ALL value providers * Avoid using `anyObjectValueProvider` that is removed in #2583 * Make `AnyObjectValueProvider` not extend any interfaces, remove unrelated comment * Fix compilation after rebase
Description
We introduce new
BuilderObjectValueProvider
for Java that finds any method, that can create a value of given type. Together withAbstractObjectValueProvider
it works only when ObjectValueProvider and others fails to build a value.The provider searches any method from any class that can return object of this type or any type that can be inferenced from the given one. It doesn't matter if this method static or not, but if this method is not static, that we suppose that we have a builder class for it. As a builder class we try to find other methods that returns an instance of this builder. This logic added because of default way to create such builder, where any set or add method returns the instance of builder to support chain calling. This builder should work to find methods for factories and singletones as well.
To support this provider, we introduce new routine in fuzzer's API called
Modify
(the name maybe is not final). It is added forSeed.Recurisve
and works as follows: it accepts a sequence of routines that changes or creates new object with given this instance and fuzzed values. For example, we firstly create builder's object and update it with builder method, then finally we call the method, that creates an object using this builder. This sequence is always called when creating an object and never changed its ordering.In addition, you can use this method, apply some method to the instance and return the instance object itself, for example, to always close a
Closable
object.As a result,
ContestEstimator
covers 53% of guava project code, before it covers only 43%.How to test
Automated tests
All fuzzer tests should pass.
Manual tests
You can try to generate tests for this little project:
Self-check list
Check off the item if the statement is true. Hint: [x] is a marked item.
Please do not delete the list or its items.