-
Notifications
You must be signed in to change notification settings - Fork 46
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
Generate test by fuzzing for methods with no parameters #511 #515
Conversation
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.
There are a couple of minor comments, but generally looks OK.
fallbackModelProvider.toModel(methodUnderTest.clazz).apply { | ||
ObjectModelProvider { nextDefaultModelId++ }.withFallback(fallbackModelProvider).generate( | ||
FuzzedMethodDescription("thisInstance", voidClassId, listOf(methodUnderTest.clazz.id), constantValues) | ||
).take(10).shuffled(Random(0)).map { it.value.model }.first().apply { |
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.
Are you purposely using the fixed seed here?
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.
Yes, fuzzer should randomize but be reproducable for same method
* @param index of the parameter in method signature | ||
* @param value fuzzed values | ||
*/ | ||
class FuzzedParameter( |
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.
Could this class be a data class?
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.
IMO, data classes creates hashCode/equals/toString that aren't necessary in most cases
@@ -462,7 +486,7 @@ class UtBotSymbolicEngine( | |||
fullPath = emptyList(), | |||
coverage = concreteExecutionResult.coverage, | |||
testMethodName = testMethodName?.testName, | |||
displayName = testMethodName?.displayName | |||
displayName = testMethodName?.takeIf { hasMethodUnderTestParametersToFuzz }?.displayName |
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.
If I understand this code right, we will not have display name for tests without parameters at all to avoid explicit "this" argument in the name?
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.
Yes, it's true
Description
This PR resolves several issues:
Fixes #511
Type of Change
How Has This Been Tested?
Automated Testing
org.utbot.framework.plugin.api.ModelProviderTest
Manual Scenario
Test method
foo
from this example:Checklist (remove irrelevant options):