-
Notifications
You must be signed in to change notification settings - Fork 47
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
Cg util class #689
Merged
Merged
Cg util class #689
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
ce1f2c8
to
c7e564c
Compare
Vassiliy-Kudryashov
approved these changes
Aug 12, 2022
f96a8f1
to
2a3cf3f
Compare
This commit moves all util methods that have previously been in the test class into a separate module. This module is built into a shadow jar which needs to be added into the user's project dependencies in order for our generated tests to be able to use its functionality.
All util methods and data provider methods are static. In Kotlin they will be placed into a companion object.
Regular classes will be used for construction of util classes.
Rewrite util method provider classes and their usage. There are 3 kinds of providers: library, test class, util class file.
If no util methods are required, then util class will not be generated. Otherwise, we will generate an util class with or without Mockito usage, depending on whether Mockito is used in the tests or not. Note that whenever an util class with Mockito is required, it will be generated and it will rewrite a previous utils file if it exists. That's because the previous file could have been without Mockito.
… multiple possible util method providers
…combinations tests
…eparate utils class instead
… to overwrite an existing util class or not
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
This MR allows moving all util methods that have previously been in the test class into a separate util class. The plugin will now generate utils in a separate class (
org.utbot.runtime.utils.UtUtils
).If no util methods are required in the generated tests, then no util class will be generated. If the generated tests require util methods, but the tests do not use mocking, then a version of util class without mockito will be generated (when mocking is used,
deepEquals
util method is a bit different). Otherwise, when mocking is used, an util class with mockito usage will be produced.For other components that use code generation the behavior may be different:
TestCodeGenerationPipeline
- Util class is generated, but only in tests where we usecheckAllCombinations()
. We check all combinations of generation settings with and without util class. But this shouldn't take much time, because we check all combinations only for a couple of classes.GenerateTestsAbstractCommand
(CLI),GenerateTestsAndSarifReportFacade
- we decided that these components should generate util class, but it is not implemented in this PR. For now they work as before, but in the future util class generation may be added.UtBotJavaApi
,Contest
- we decided that these components should not generate util class. They work as before, util methods are generated directly in the test class.Type of Change
How Has This Been Tested?
Automated Testing
Specify tests that help to verify the change automatically.
The following tests use function
checkAllCombinations()
that runs test generation with all configurations:org.utbot.examples.codegen.CodegenExampleTest
org.utbot.examples.enums.ClassWithEnumTest#testOrdinal
Now all of these configurations also run with AND without a separate util class. This way the new feature is tested in the pipeline.
Manual Scenario
Note that util class can be overwritten if needed. This can be demonstrated and tested with the following actions:
Checklist: