Skip to content
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

Avoid dynamic mocks for common "data" types #2593

Open
IlyaMuravjov opened this issue Sep 11, 2023 · 0 comments
Open

Avoid dynamic mocks for common "data" types #2593

IlyaMuravjov opened this issue Sep 11, 2023 · 0 comments
Labels
comp-instrumented-process Issue is related to Instrumented process comp-spring Issue is related to Spring projects support ctg-enhancement New feature, improvement or change request

Comments

@IlyaMuravjov
Copy link
Collaborator

IlyaMuravjov commented Sep 11, 2023

Description

Right now in Spring unit tests fuzzer when initially creating mocks doesn't mock any methods. Only when it gets feedback from the concrete execution about invoked methods it does the actual mocking of these method. Although, even after that it may still choose not to mock them (e.g. if they are too deep, by default fuzzer recursion depth limit is set to 4).

To complete concrete execution when invoked method of the mock is not mocked, we create answers at runtime. For most types we use mocks as default answers, to achieve maximum coverage and make discovery of methods to mock faster.

However, that sometimes causes us to mock types that should not be normally mocked (e.g. List and Optional).

That is bad because mocks of such types can have a nonsensical behavior (e.g. we can have List that returns false when isEmpty() is called on it, while returning 0 when size() is called on it), also, sometimes mocks are unable to cover certain instructions, for example, if we mock Optional we won't be able to cover lambda that is passed to orElseGet method).

@IlyaMuravjov IlyaMuravjov added ctg-enhancement New feature, improvement or change request comp-instrumented-process Issue is related to Instrumented process comp-spring Issue is related to Spring projects support labels Sep 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp-instrumented-process Issue is related to Instrumented process comp-spring Issue is related to Spring projects support ctg-enhancement New feature, improvement or change request
Projects
Status: Todo
Development

No branches or pull requests

1 participant