Skip to content

Commit 66f97e5

Browse files
committed
Minor refactoring: avoid code duplication
1 parent 464acbe commit 66f97e5

File tree

4 files changed

+8
-35
lines changed

4 files changed

+8
-35
lines changed

utbot-summary-tests/src/test/kotlin/examples/SummaryTestCaseGeneratorTest.kt

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,15 @@ open class SummaryTestCaseGeneratorTest(
5050
summaryKeys: List<String>,
5151
methodNames: List<String> = listOf(),
5252
displayNames: List<String> = listOf(),
53-
clusterInfo: List<Pair<UtClusterInfo, Int>> = listOf()
53+
clusterInfo: List<Pair<UtClusterInfo, Int>> = listOf(),
54+
useCustomTags: Boolean = false
5455
) {
5556
workaround(WorkaroundReason.HACK) {
5657
// @todo change to the constructor parameter
5758
checkSolverTimeoutMillis = 0
5859
checkNpeInNestedMethods = true
5960
checkNpeInNestedNotPrivateMethods = true
60-
UtSummarySettings.USE_CUSTOM_JAVADOC_TAGS = false
61+
UtSummarySettings.USE_CUSTOM_JAVADOC_TAGS = useCustomTags
6162
}
6263
val utMethod = UtMethod.from(method)
6364
val testSet = executionsModel(utMethod, mockStrategy)
@@ -69,34 +70,6 @@ open class SummaryTestCaseGeneratorTest(
6970
testSetWithSummarization.checkClusterInfo(clusterInfo)
7071
}
7172

72-
/**
73-
* Checks summaries containing custom JavaDoc tags.
74-
*/
75-
inline fun <reified R> checkSummariesWithCustomTags(
76-
method: KFunction<R>,
77-
mockStrategy: MockStrategyApi,
78-
coverageMatcher: CoverageMatcher,
79-
summaryKeys: List<String>,
80-
methodNames: List<String>,
81-
displayNames: List<String>
82-
) {
83-
workaround(WorkaroundReason.HACK) {
84-
// @todo change to the constructor parameter
85-
checkSolverTimeoutMillis = 0
86-
checkNpeInNestedMethods = true
87-
checkNpeInNestedNotPrivateMethods = true
88-
UtSummarySettings.USE_CUSTOM_JAVADOC_TAGS = true
89-
}
90-
val utMethod = UtMethod.from(method)
91-
val testSet = executionsModel(utMethod, mockStrategy)
92-
testSet.summarize(searchDirectory)
93-
testSet.clustersInfo
94-
95-
testSet.executions.checkMatchersWithCustomTagsInSummary(summaryKeys)
96-
testSet.executions.checkMatchersWithMethodNames(methodNames)
97-
testSet.executions.checkMatchersWithDisplayNames(displayNames)
98-
}
99-
10073
/**
10174
* It removes from the String all whitespaces, tabs etc.
10275
*

utbot-summary-tests/src/test/kotlin/examples/controlflow/SummaryConditionsTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,6 @@ class SummaryConditionsTest : SummaryTestCaseGeneratorTest(
4646
val mockStrategy = MockStrategyApi.NO_MOCKS
4747
val coverage = DoNotCalculate
4848

49-
checkSummariesWithCustomTags(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames)
49+
summaryCheck(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames, useCustomTags = true)
5050
}
5151
}

utbot-summary-tests/src/test/kotlin/examples/exceptions/SummaryExceptionClusteringExamplesTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,6 @@ class SummaryExceptionClusteringExamplesTest : SummaryTestCaseGeneratorTest(
6969
val mockStrategy = MockStrategyApi.NO_MOCKS
7070
val coverage = DoNotCalculate
7171

72-
checkSummariesWithCustomTags(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames)
72+
summaryCheck(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames, useCustomTags = true)
7373
}
7474
}

utbot-summary-tests/src/test/kotlin/examples/structures/SummaryMinStackTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class SummaryMinStackTest : SummaryTestCaseGeneratorTest(
5353
val mockStrategy = MockStrategyApi.NO_MOCKS
5454
val coverage = DoNotCalculate
5555

56-
checkSummariesWithCustomTags(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames)
56+
summaryCheck(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames, useCustomTags = true)
5757
}
5858

5959
@Test
@@ -92,7 +92,7 @@ class SummaryMinStackTest : SummaryTestCaseGeneratorTest(
9292
val mockStrategy = MockStrategyApi.NO_MOCKS
9393
val coverage = DoNotCalculate
9494

95-
checkSummariesWithCustomTags(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames)
95+
summaryCheck(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames, useCustomTags = true)
9696
}
9797

9898
@Test
@@ -197,6 +197,6 @@ class SummaryMinStackTest : SummaryTestCaseGeneratorTest(
197197
val mockStrategy = MockStrategyApi.NO_MOCKS
198198
val coverage = DoNotCalculate
199199

200-
checkSummariesWithCustomTags(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames)
200+
summaryCheck(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames, useCustomTags = true)
201201
}
202202
}

0 commit comments

Comments
 (0)