Skip to content

Rename mock strategy options in gradle and maven plugins #369

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
Jul 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ interface SarifExtensionProvider {

fun mockStrategyParse(mockStrategy: String): MockStrategyApi =
when (mockStrategy.toLowerCase()) {
"do-not-mock" -> MockStrategyApi.NO_MOCKS
"package-based" -> MockStrategyApi.OTHER_PACKAGES
"all-except-cut" -> MockStrategyApi.OTHER_CLASSES
else -> error("Parameter mockStrategy == '$mockStrategy', but it can take only 'do-not-mock', 'package-based' or 'all-except-cut'")
"no-mocks" -> MockStrategyApi.NO_MOCKS
"other-packages" -> MockStrategyApi.OTHER_PACKAGES
"other-classes" -> MockStrategyApi.OTHER_CLASSES
else -> error("Parameter mockStrategy == '$mockStrategy', but it can take only 'no-mocks', 'other-packages' or 'other-classes'")
}

fun staticsMockingParse(staticsMocking: String): StaticsMocking =
Expand Down
10 changes: 5 additions & 5 deletions utbot-gradle/docs/utbot-gradle.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ __Groovy:__
mockFramework = 'mockito'
generationTimeout = 60000L
codegenLanguage = 'java'
mockStrategy = 'package-based'
mockStrategy = 'other-packages'
staticsMocking = 'mock-statics'
forceStaticMocking = 'force'
classesToMockAlways = ['org.slf4j.Logger', 'java.util.Random']
Expand All @@ -62,7 +62,7 @@ __Kotlin DSL:__
mockFramework.set("mockito")
generationTimeout.set(60000L)
codegenLanguage.set("java")
mockStrategy.set("package-based")
mockStrategy.set("other-packages")
staticsMocking.set("mock-statics")
forceStaticMocking.set("force")
classesToMockAlways.set(listOf("org.slf4j.Logger", "java.util.Random"))
Expand Down Expand Up @@ -118,9 +118,9 @@ __Kotlin DSL:__
- `mockStrategy` –
- The mock strategy to be used.
- Can be one of:
- `'do-not-mock'` – do not use mock frameworks at all
- `'package-based'` – mock all classes outside the current package except system ones _(by default)_
- `'all-except-cut'` – mock all classes outside the class under test except system ones
- `'no-mocks'` – do not use mock frameworks at all
- `'other-packages'` – mock all classes outside the current package except system ones _(by default)_
- `'other-classes'` – mock all classes outside the class under test except system ones

- `staticsMocking` –
- Use static methods mocking or not.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ abstract class SarifGradleExtension {
abstract val codegenLanguage: Property<String>

/**
* Can be one of: 'do-not-mock', 'package-based', 'all-except-cut'.
* Can be one of: 'no-mocks', 'other-packages', 'other-classes'.
*/
@get:Input
abstract val mockStrategy: Property<String>
Expand Down Expand Up @@ -105,7 +105,7 @@ sarifReport {
mockFramework = 'mockito'
generationTimeout = 60 * 1000L
codegenLanguage = 'java'
mockStrategy = 'do-not-mock'
mockStrategy = 'no-mocks'
staticsMocking = 'do-not-mock-statics'
forceStaticMocking = 'force'
classesToMockAlways = ['org.utbot.api.mock.UtMock']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,19 +256,19 @@ class SarifGradleExtensionProviderTest {

@Test
fun `should be equal to NO_MOCKS`() {
setMockStrategy("do-not-mock")
setMockStrategy("no-mocks")
assertEquals(MockStrategyApi.NO_MOCKS, extensionProvider.mockStrategy)
}

@Test
fun `should be equal to OTHER_PACKAGES`() {
setMockStrategy("package-based")
setMockStrategy("other-packages")
assertEquals(MockStrategyApi.OTHER_PACKAGES, extensionProvider.mockStrategy)
}

@Test
fun `should be equal to OTHER_CLASSES`() {
setMockStrategy("all-except-cut")
setMockStrategy("other-classes")
assertEquals(MockStrategyApi.OTHER_CLASSES, extensionProvider.mockStrategy)
}

Expand Down
8 changes: 4 additions & 4 deletions utbot-maven/docs/utbot-maven.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ For example, the following configuration may be used:
<mockFramework>mockito</mockFramework>
<generationTimeout>60000L</generationTimeout>
<codegenLanguage>java</codegenLanguage>
<mockStrategy>package-based</mockStrategy>
<mockStrategy>other-packages</mockStrategy>
<staticsMocking>mock-statics</staticsMocking>
<forceStaticMocking>force</forceStaticMocking>
<classesToMockAlways>
Expand Down Expand Up @@ -104,9 +104,9 @@ For example, the following configuration may be used:
- `mockStrategy` &ndash;
- The mock strategy to be used.
- Can be one of:
- `'do-not-mock'` &ndash; do not use mock frameworks at all
- `'package-based'` &ndash; mock all classes outside the current package except system ones _(by default)_
- `'all-except-cut'` &ndash; mock all classes outside the class under test except system ones
- `'no-mocks'` &ndash; do not use mock frameworks at all
- `'other-packages'` &ndash; mock all classes outside the current package except system ones _(by default)_
- `'other-classes'` &ndash; mock all classes outside the class under test except system ones

- `staticsMocking` &ndash;
- Use static methods mocking or not.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ class GenerateTestsAndSarifReportMojo : AbstractMojo() {
internal lateinit var codegenLanguage: String

/**
* Can be one of: 'do-not-mock', 'package-based', 'all-except-cut'.
* Can be one of: 'no-mocks', 'other-packages', 'other-classes'.
*/
@Parameter(defaultValue = "do-not-mock")
@Parameter(defaultValue = "no-mocks")
internal lateinit var mockStrategy: String

/**
Expand Down
2 changes: 1 addition & 1 deletion utbot-maven/src/test/resources/project-to-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<mockFramework>mockito</mockFramework>
<generationTimeout>10000</generationTimeout>
<codegenLanguage>java</codegenLanguage>
<mockStrategy>package-based</mockStrategy>
<mockStrategy>other-packages</mockStrategy>
<staticsMocking>mock-statics</staticsMocking>
<forceStaticMocking>force</forceStaticMocking>
<classesToMockAlways>
Expand Down