Skip to content

Introduce and test UtBotSpringApi #2632

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

Merged
merged 6 commits into from
Oct 5, 2023
Merged

Conversation

IlyaMuravjov
Copy link
Collaborator

@IlyaMuravjov IlyaMuravjov commented Oct 2, 2023

Description

Add UtBotSpringApi that helps UtBotJavaApi users create SpringApplicationContext to run Spring-specific test generation (see #2614)

How to test

Automated tests

The proposed changes are verified with tests:
utbot-spring-test/src/test/java/org/utbot/examples/spring/manual/UtBotSpringApiTest.java

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.

@IlyaMuravjov IlyaMuravjov added comp-spring Issue is related to Spring projects support ctg-enhancement New feature, improvement or change request labels Oct 2, 2023
@IlyaMuravjov IlyaMuravjov marked this pull request as ready for review October 2, 2023 09:01
* hence call to this method is added into them to ensure they are actually never called.
*/
public static void shouldNeverBeCalled() {
System.err.println("shouldNeverBeCalled() is unexpectedly called");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will we see this message in log on CI? If yes, maybe stack trace would be more useful.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I doubt we will see it on CI. Spring analyzer runs in a separate process and similarly to instrumented process it uses RD logger to send logs to engine process which can actually print them. However, RD logger isn't configured in the sample Spring project.

So if these tests start failing due to Spring analyzer initializing beans it may take some time to debug them and find the problem, but it's unlikely, so I think it's not worth configuring RD logger in sample Spring project now.

public void testOnAbsentSpringSettings() {
SpringApplicationContext springApplicationContext =
UtBotSpringApi.createSpringApplicationContext(
SpringSettings.AbsentSpringSettings.INSTANCE,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can turn AbsentSpringSettings into companion object and get rid of the INSTANCE call

@IlyaMuravjov IlyaMuravjov merged commit 389fe66 into main Oct 5, 2023
@IlyaMuravjov IlyaMuravjov deleted the ilya_m/ut-bot-spring-api branch October 5, 2023 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp-spring Issue is related to Spring projects support ctg-enhancement New feature, improvement or change request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants