GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Support mock strategies and type replacement in Spring unit test fuzzing by IlyaMuravjov · Pull Request #2561 · UnitTestBot/UTBotJava

Conversation

@IlyaMuravjov

@IlyaMuravjov IlyaMuravjov commented Aug 28, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

Description

Makes fuzzing in Spring unit tests respect mock strategy and type replacement:

  • All types are replaced according to selected Spring configuration before they are passed to actual value providers.
  • MockValueProvider is used if mock strategy allows it and type isn't replaced, otherwise ObjectValueProvider 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 create thisInstance.

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

  • I've set the proper labels for my PR (at least, for category and component).
  • PR title and description are clear and intelligible.
  • I've added enough comments to my code, particularly in hard-to-understand areas.
  • The functionality I've repaired, changed or added is covered with automated tests.
  • Manual tests have been provided optionally.
  • The documentation for the functionality I've been working on is up-to-date.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@IlyaMuravjov IlyaMuravjov added ctg-enhancement New feature, improvement or change request comp-fuzzing Issue is related to the fuzzing comp-spring Issue is related to Spring projects support labels Aug 28, 2023
@IlyaMuravjov
IlyaMuravjov force-pushed the ilya_m/unit_test_fuzz_modes branch 2 times, most recently from 701fb39 to 163e168 Compare August 29, 2023 12:48
@IlyaMuravjov
IlyaMuravjov requested a review from EgorkaKulikov August 29, 2023 13:36
@IlyaMuravjov
IlyaMuravjov marked this pull request as ready for review August 29, 2023 13:36
@IlyaMuravjov
IlyaMuravjov requested review from Damtev and Vassiliy-Kudryashov and removed request for Vassiliy-Kudryashov September 5, 2023 20:22
@Damtev

Damtev commented Sep 11, 2023

Copy link
Copy Markdown
Member

@Markoutte, could you take a look, please?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@IlyaMuravjov
IlyaMuravjov force-pushed the ilya_m/unit_test_fuzz_modes branch from 1ba7d74 to b130123 Compare September 11, 2023 16:34
Markoutte
Markoutte reviewed Sep 12, 2023
View reviewed changes

@Markoutte Markoutte left a comment

Copy link
Copy Markdown
Collaborator

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?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread utbot-java-fuzzing/src/main/kotlin/org/utbot/fuzzing/providers/Objects.kt Outdated
* 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

@Markoutte Markoutte Sep 12, 2023

Copy link
Copy Markdown
Collaborator

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@IlyaMuravjov IlyaMuravjov Sep 15, 2023

Copy link
Copy Markdown
Collaborator Author

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
IlyaMuravjov added 10 commits September 19, 2023 10:50
@IlyaMuravjov
Support mock strategies and type replacement in Spring unit test fuzzing
c15e554
@IlyaMuravjov
Avoid mocking replaced types
eea12f1
@IlyaMuravjov
Only use InjectMockValueProvider for thisInstance
badfd3b
@IlyaMuravjov
Disallow non-mocks when mock can be used
3a15ae3
@IlyaMuravjov
Move all value provider decorators to one package
cce1616
@IlyaMuravjov
Improve adding of ReplacedFuzzedTypeFlag
beef34f
@IlyaMuravjov
Make map and except apply transformer/filter to ALL value providers
9ea8815
@IlyaMuravjov
Avoid using anyObjectValueProvider that is removed in #2583
f64a5b7
@IlyaMuravjov
Make AnyObjectValueProvider not extend any interfaces, remove unrel…
33c1c21
…ated comment
@IlyaMuravjov
Fix compilation after rebase
98da383
@IlyaMuravjov
IlyaMuravjov force-pushed the ilya_m/unit_test_fuzz_modes branch from 7f325a4 to 98da383 Compare September 19, 2023 11:07
@alisevych alisevych added this to the September Release milestone Sep 19, 2023
EgorkaKulikov
EgorkaKulikov approved these changes Sep 19, 2023
View reviewed changes
@EgorkaKulikov
EgorkaKulikov merged commit 36c23ff into main Sep 19, 2023
@EgorkaKulikov
EgorkaKulikov deleted the ilya_m/unit_test_fuzz_modes branch September 19, 2023 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@Markoutte Markoutte Markoutte left review comments
@EgorkaKulikov EgorkaKulikov EgorkaKulikov approved these changes
@Damtev Damtev Awaiting requested review from Damtev

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

comp-fuzzing Issue is related to the fuzzing comp-spring Issue is related to Spring projects support ctg-enhancement New feature, improvement or change request

Projects

None yet

Milestone

October Release

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@IlyaMuravjov @Damtev @Markoutte @EgorkaKulikov @alisevych
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.