Skip to content

Removed unnecessary mock counter and switch during constructors mocking #1880

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 2 commits into from
Mar 3, 2023

Conversation

Damtev
Copy link
Member

@Damtev Damtev commented Mar 2, 2023

Description

Fixes #1878.

How to test

Automated tests

Common pipeline.

Manual tests

The same as in the corresponding issue.

Generated test:

///region Test suites for executable org.utbot.examples.mock.provider.impl.ProviderImpl.provideObject

///region SYMBOLIC EXECUTION: SUCCESSFUL EXECUTIONS for method provideObject()

/**
 * @utbot.classUnderTest {@link ProviderImpl}
 * @utbot.methodUnderTest {@link ProviderImpl#provideObject()}
 * @utbot.returnsFrom {@code return new ExampleClass(0);}
 */
@Test
@DisplayName("provideObject: -> return new ExampleClass(0)")
public void testProvideObject_Return() {
	org.mockito.MockedConstruction mockedConstruction = null;
	try {
		mockedConstruction = mockConstruction(ExampleClass.class, (ExampleClass ExampleClassMock, org.mockito.MockedConstruction.Context context) -> {
		});
		ProviderImpl providerImpl = new ProviderImpl();

		ExampleClass actual = providerImpl.provideObject();

		ExampleClass expectedMock = mock(ExampleClass.class);
		expectedMock.field = 0;
                // org.utbot.examples.mock.service.impl.ExampleClass has overridden equals method
                assertEquals(expectedMock, actual);
	} finally {
		mockedConstruction.close();
	}
}
///endregion

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.

@Damtev Damtev added ctg-enhancement New feature, improvement or change request comp-codegen Issue is related to code generator labels Mar 2, 2023
@Damtev Damtev requested a review from EgorkaKulikov March 2, 2023 09:57
@Damtev Damtev marked this pull request as ready for review March 2, 2023 09:57
@Damtev Damtev force-pushed the damtev/new_instance_mocks_fixes branch from b40571e to 6f01a61 Compare March 3, 2023 08:54
@Damtev Damtev requested a review from EgorkaKulikov March 3, 2023 08:54
@Damtev Damtev enabled auto-merge (squash) March 3, 2023 09:08
@Damtev Damtev merged commit 29fdb41 into main Mar 3, 2023
@Damtev Damtev deleted the damtev/new_instance_mocks_fixes branch March 3, 2023 09:27
@alisevych alisevych added this to the 2023.03 Release milestone Mar 21, 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 ctg-enhancement New feature, improvement or change request
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Remove switch and mockClassCounter in mockConstruction in simple mockConstruction cases
3 participants