-
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
Use controllers via MockMvc
in Spring integration tests
#2447
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IlyaMuravjov
force-pushed
the
ilya_m/mock_mvc
branch
3 times, most recently
from
July 28, 2023 11:52
3996ba1
to
e26100f
Compare
IlyaMuravjov
added
comp-spring
Issue is related to Spring projects support
ctg-enhancement
New feature, improvement or change request
comp-codegen
Issue is related to code generator
comp-instrumented-process
Issue is related to Instrumented process
labels
Jul 28, 2023
utbot-framework-api/src/main/kotlin/org/utbot/framework/plugin/api/Api.kt
Outdated
Show resolved
Hide resolved
utbot-framework-api/src/main/kotlin/org/utbot/framework/plugin/api/Api.kt
Outdated
Show resolved
Hide resolved
utbot-framework/src/main/kotlin/org/utbot/framework/codegen/tree/CgMethodConstructor.kt
Show resolved
Hide resolved
utbot-framework/src/main/kotlin/org/utbot/framework/codegen/tree/CgMethodConstructor.kt
Outdated
Show resolved
Hide resolved
.../src/main/kotlin/org/utbot/framework/codegen/tree/CgMockMvcResultActionsAssertConstructor.kt
Outdated
Show resolved
Hide resolved
...otlin/org/utbot/instrumentation/instrumentation/execution/constructors/UtModelConstructor.kt
Outdated
Show resolved
Hide resolved
...kotlin/org/utbot/instrumentation/instrumentation/execution/context/InstrumentationContext.kt
Outdated
Show resolved
Hide resolved
.../kotlin/org/utbot/instrumentation/instrumentation/spring/SpringUtExecutionInstrumentation.kt
Show resolved
Hide resolved
...n/org/utbot/instrumentation/instrumentation/spring/UtMockMvcResultActionsModelConstructor.kt
Show resolved
Hide resolved
...otlin/org/utbot/python/framework/codegen/model/constructor/tree/PythonCgMethodConstructor.kt
Outdated
Show resolved
Hide resolved
IlyaMuravjov
added a commit
that referenced
this pull request
Jul 31, 2023
IlyaMuravjov
added a commit
that referenced
this pull request
Jul 31, 2023
IlyaMuravjov
force-pushed
the
ilya_m/mock_mvc
branch
from
July 31, 2023 15:02
b43c6b9
to
eabd6d5
Compare
…pping` on controller class
…executablesToCall`
IlyaMuravjov
force-pushed
the
ilya_m/mock_mvc
branch
from
July 31, 2023 15:12
eabd6d5
to
e5dd7c1
Compare
EgorkaKulikov
approved these changes
Aug 1, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
comp-codegen
Issue is related to code generator
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
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.
Description
Fixes #2345
Also fixes #2227
This PR makes integration tests for Spring controllers instead of calling controllers directly, call them via
MockMvc.perform()
and useandExpect()
to do asserts.In order to achieve that:
methodUnderTest
andmethodToCall
were separated (methodToCall
can be set inEnvironmentModels
)ConcreteExecutionContext
was allowed to modifystateBefore
(includingmethodToCall
)UtCustomModel
was introduced to describe models with additional custom data (it hasorigin
that can be used in common UtBot code base)InstrumentationContext
was enriched to provideUtCustomModelConstructor
s (including previously existing subclasses ofUtAssembleModelConstructorBase
)CgSimpleCustomAssertConstructor
was introduced to generate more human readable assertions whenexpectedResult
isUtCustomModel
(makes Avoid generating many reflection statements for LinkedHashMap #2227 no longer relevant for Spring controllers)Example:
How to test
Manual tests
Generate integration tests for
OrderController
inspring-boot-testing
project, there should be tests that useMockMvc
.Self-check list