Skip to content

Commit 19543ab

Browse files
committed
Introduce utbot-framework-test project
1 parent e0b2fc8 commit 19543ab

File tree

253 files changed

+979
-1054
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

253 files changed

+979
-1054
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ antlr_version=4.9.2
2727
kryo_version=5.3.0
2828
kryo_serializers_version=0.45
2929
asm_version=9.2
30-
testng_version=7.4.0
30+
testng_version=7.6.0
3131
mockito_inline_version=4.0.0
3232
jackson_version = 2.12.3
3333
javasmt_solver_z3_version=4.8.9-sosy1

settings.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,6 @@ include 'utbot-summary'
2727
include 'utbot-gradle'
2828
//include 'utbot-maven'
2929
include 'utbot-summary-tests'
30+
include 'utbot-framework-test'
3031
include 'utbot-rd'
3132

utbot-analytics/src/test/kotlin/org/utbot/features/FeatureProcessorWithRepetitionTest.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import org.junit.jupiter.api.Assertions
55
import org.junit.jupiter.api.BeforeAll
66
import org.junit.jupiter.api.Test
77
import org.utbot.analytics.EngineAnalyticsContext
8-
import org.utbot.examples.UtValueTestCaseChecker
9-
import org.utbot.examples.eq
10-
import org.utbot.examples.withFeaturePath
8+
import org.utbot.tests.infrastructure.UtValueTestCaseChecker
9+
import org.utbot.testcheckers.eq
10+
import org.utbot.testcheckers.withFeaturePath
1111
import java.io.File
1212
import java.io.FileInputStream
1313

14-
class FeatureProcessorWithRepetitionTest : UtValueTestCaseChecker(OnePath::class, false) {
14+
class FeatureProcessorWithRepetitionTest: UtValueTestCaseChecker(OnePath::class, false) {
1515
companion object {
1616
const val featureDir = "src/test/resources/features"
1717
fun reward(coverage: Double, time: Double) = RewardEstimator.reward(coverage, time)

utbot-analytics/src/test/kotlin/org/utbot/predictors/LinearStateRewardPredictorTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ package org.utbot.predictors
22

33
import org.junit.jupiter.api.Assertions.assertEquals
44
import org.junit.jupiter.api.Test
5-
import org.utbot.examples.withPathSelectorType
6-
import org.utbot.examples.withRewardModelPath
75
import org.utbot.framework.PathSelectorType
86
import org.utbot.framework.UtSettings
7+
import org.utbot.testcheckers.withPathSelectorType
8+
import org.utbot.testcheckers.withRewardModelPath
99

1010
class LinearStateRewardPredictorTest {
1111
@Test

utbot-analytics/src/test/kotlin/org/utbot/predictors/NNStateRewardPredictorTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ package org.utbot.predictors
33
import org.junit.jupiter.api.Assertions.assertEquals
44
import org.junit.jupiter.api.Disabled
55
import org.junit.jupiter.api.Test
6-
import org.utbot.examples.withPathSelectorType
76
import org.utbot.analytics.StateRewardPredictor
8-
import org.utbot.examples.withRewardModelPath
97
import org.utbot.framework.PathSelectorType
108
import org.utbot.framework.UtSettings
9+
import org.utbot.testcheckers.withPathSelectorType
10+
import org.utbot.testcheckers.withRewardModelPath
1111
import kotlin.system.measureNanoTime
1212

1313
class NNStateRewardPredictorTest {

utbot-cli/build.gradle

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
apply from: "${parent.projectDir}/gradle/include/jvm-project.gradle"
22

3+
compileKotlin {
4+
kotlinOptions {
5+
jvmTarget = JavaVersion.VERSION_11
6+
freeCompilerArgs += ["-Xallow-result-return-type", "-Xsam-conversions=class"]
7+
}
8+
}
9+
10+
java {
11+
sourceCompatibility = JavaVersion.VERSION_1_8
12+
targetCompatibility = JavaVersion.VERSION_11
13+
}
14+
15+
316
//noinspection GroovyAssignabilityCheck
417
configurations {
518
fetchInstrumentationJar
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package org.utbot.testcheckers
2+
3+
fun ge(count: Int) = ExecutionsNumberMatcher("ge $count") { it >= count }
4+
5+
fun eq(count: Int) = ExecutionsNumberMatcher("eq $count") { it == count }
6+
7+
fun between(bounds: IntRange) = ExecutionsNumberMatcher("$bounds") { it in bounds }
8+
9+
class ExecutionsNumberMatcher(private val description: String, private val cmp: (Int) -> Boolean) {
10+
operator fun invoke(x: Int) = cmp(x)
11+
override fun toString() = description
12+
}
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
package org.utbot.testcheckers
2+
3+
import org.utbot.framework.PathSelectorType
4+
import org.utbot.framework.TestSelectionStrategyType
5+
import org.utbot.framework.UtSettings
6+
7+
inline fun <reified T> withFeaturePath(featurePath: String, block: () -> T): T {
8+
val prevFeaturePath = UtSettings.featurePath
9+
val prevEnableFeatureProcess = UtSettings.enableFeatureProcess
10+
11+
UtSettings.featurePath = featurePath
12+
UtSettings.enableFeatureProcess = true
13+
14+
try {
15+
return block()
16+
} finally {
17+
UtSettings.featurePath = prevFeaturePath
18+
UtSettings.enableFeatureProcess = prevEnableFeatureProcess
19+
}
20+
}
21+
22+
inline fun <reified T> withUsingReflectionForMaximizingCoverage(maximizeCoverage: Boolean, block: () -> T): T {
23+
val prev = UtSettings.maximizeCoverageUsingReflection
24+
UtSettings.maximizeCoverageUsingReflection = maximizeCoverage
25+
try {
26+
return block()
27+
} finally {
28+
UtSettings.maximizeCoverageUsingReflection = prev
29+
}
30+
}
31+
32+
inline fun <reified T> withPathSelectorType(pathSelectorType: PathSelectorType, block: () -> T): T {
33+
val prev = UtSettings.pathSelectorType
34+
UtSettings.pathSelectorType = pathSelectorType
35+
try {
36+
return block()
37+
} finally {
38+
UtSettings.pathSelectorType = prev
39+
}
40+
}
41+
42+
inline fun <reified T> withRewardModelPath(rewardModelPath: String, block: () -> T): T {
43+
val prev = UtSettings.rewardModelPath
44+
UtSettings.rewardModelPath = rewardModelPath
45+
try {
46+
return block()
47+
} finally {
48+
UtSettings.rewardModelPath = prev
49+
}
50+
}
51+
52+
inline fun <reified T> withTreatingOverflowAsError(block: () -> T): T {
53+
val prev = UtSettings.treatOverflowAsError
54+
UtSettings.treatOverflowAsError = true
55+
try {
56+
return block()
57+
} finally {
58+
UtSettings.treatOverflowAsError = prev
59+
}
60+
}
61+
62+
inline fun <reified T> withPushingStateFromPathSelectorForConcrete(block: () -> T): T {
63+
val prev = UtSettings.saveRemainingStatesForConcreteExecution
64+
UtSettings.saveRemainingStatesForConcreteExecution = true
65+
try {
66+
return block()
67+
} finally {
68+
UtSettings.saveRemainingStatesForConcreteExecution = prev
69+
}
70+
}
71+
72+
inline fun <T> withoutSubstituteStaticsWithSymbolicVariable(block: () -> T) {
73+
val substituteStaticsWithSymbolicVariable = UtSettings.substituteStaticsWithSymbolicVariable
74+
UtSettings.substituteStaticsWithSymbolicVariable = false
75+
try {
76+
block()
77+
} finally {
78+
UtSettings.substituteStaticsWithSymbolicVariable = substituteStaticsWithSymbolicVariable
79+
}
80+
}
81+
82+
inline fun <reified T> withoutMinimization(block: () -> T): T {
83+
val prev = UtSettings.testMinimizationStrategyType
84+
UtSettings.testMinimizationStrategyType = TestSelectionStrategyType.DO_NOT_MINIMIZE_STRATEGY
85+
try {
86+
return block()
87+
} finally {
88+
UtSettings.testMinimizationStrategyType = prev
89+
}
90+
}
91+
92+
inline fun <reified T> withSolverTimeoutInMillis(timeoutInMillis: Int, block: () -> T): T {
93+
val prev = UtSettings.checkSolverTimeoutMillis
94+
UtSettings.checkSolverTimeoutMillis = timeoutInMillis
95+
try {
96+
return block()
97+
} finally {
98+
UtSettings.checkSolverTimeoutMillis = prev
99+
}
100+
}
101+
102+
inline fun <reified T> withoutConcrete(block: () -> T): T {
103+
val prev = UtSettings.useConcreteExecution
104+
UtSettings.useConcreteExecution = false
105+
try {
106+
return block()
107+
} finally {
108+
UtSettings.useConcreteExecution = prev
109+
}
110+
}

utbot-framework-test/build.gradle

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
apply from: "${parent.projectDir}/gradle/include/jvm-project.gradle"
2+
3+
compileKotlin {
4+
kotlinOptions {
5+
jvmTarget = JavaVersion.VERSION_11
6+
freeCompilerArgs += ["-Xallow-result-return-type", "-Xsam-conversions=class"]
7+
}
8+
}
9+
10+
11+
java {
12+
sourceCompatibility = JavaVersion.VERSION_1_8
13+
targetCompatibility = JavaVersion.VERSION_11
14+
}
15+
16+
//noinspection GroovyAssignabilityCheck
17+
repositories {
18+
flatDir {
19+
dirs 'dist'
20+
}
21+
}
22+
23+
//noinspection GroovyAssignabilityCheck
24+
configurations {
25+
z3native
26+
}
27+
28+
dependencies {
29+
api project(':utbot-api')
30+
api project(':utbot-fuzzers')
31+
api project(':utbot-core')
32+
api project(':utbot-instrumentation')
33+
api project(':utbot-summary')
34+
api project(':utbot-framework-api')
35+
36+
implementation(project(":utbot-framework"))
37+
testImplementation project(':utbot-sample')
38+
testImplementation project(":utbot-framework").sourceSets.test.output
39+
testImplementation project(":utbot-core").sourceSets.test.output
40+
41+
implementation "com.github.UnitTestBot:soot:${soot_commit_hash}"
42+
43+
implementation group: 'com.fasterxml.jackson.module', name: 'jackson-module-kotlin', version: jackson_version
44+
implementation group: 'org.sosy-lab', name: 'javasmt-solver-z3', version: javasmt_solver_z3_version
45+
implementation group: 'com.github.curious-odd-man', name: 'rgxgen', version: rgxgen_version
46+
implementation group: 'org.apache.logging.log4j', name: 'log4j-slf4j-impl', version: log4j2_version
47+
implementation group: 'io.github.microutils', name: 'kotlin-logging', version: kotlin_logging_version
48+
implementation group: 'org.jacoco', name: 'org.jacoco.report', version: jacoco_version
49+
implementation group: 'org.apache.commons', name: 'commons-text', version: apache_commons_text_version
50+
// we need this for construction mocks from composite models
51+
implementation group: 'org.mockito', name: 'mockito-core', version: '4.2.0'
52+
53+
// To use JUnit4, comment out JUnit5 and uncomment JUnit4 dependencies here. Please also check "test" section
54+
// testImplementation group: 'junit', name: 'junit', version: '4.13.1'
55+
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: '5.8.1'
56+
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.8.1'
57+
58+
// used for testing code generation
59+
testImplementation group: 'commons-io', name: 'commons-io', version: commons_io_version
60+
testImplementation group: 'junit', name: 'junit', version: junit4_version
61+
testImplementation group: 'org.junit.platform', name: 'junit-platform-console-standalone', version: junit4_platform_version
62+
testImplementation group: 'org.antlr', name: 'antlr4', version: antlr_version
63+
testImplementation group: 'org.mockito', name: 'mockito-core', version: mockito_version
64+
testImplementation group: 'org.testng', name: 'testng', version: testng_version
65+
testImplementation group: 'org.mockito', name: 'mockito-inline', version: mockito_inline_version
66+
testImplementation group: 'com.google.guava', name: 'guava', version: guava_version
67+
68+
testImplementation group: 'org.mockito', name: 'mockito-inline', version: mockito_inline_version
69+
testImplementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: log4j2_version
70+
71+
z3native group: 'com.microsoft.z3', name: 'z3-native-win64', version: z3_version, ext: 'zip'
72+
z3native group: 'com.microsoft.z3', name: 'z3-native-linux64', version: z3_version, ext: 'zip'
73+
z3native group: 'com.microsoft.z3', name: 'z3-native-osx', version: z3_version, ext: 'zip'
74+
}
75+
76+
77+
test {
78+
79+
minHeapSize = "128m"
80+
maxHeapSize = "2048m"
81+
82+
jvmArgs '-XX:MaxHeapSize=2048m'
83+
84+
// To use JUnit4, comment out useJUnitPlatform and uncomment useJUnit. Please also check "dependencies" section
85+
//useJUnit()
86+
useJUnitPlatform() {
87+
excludeTags 'slow', 'IntegrationTest'
88+
}
89+
if (System.getProperty('DEBUG', 'false') == 'true') {
90+
jvmArgs '-Xdebug', '-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=9009'
91+
}
92+
}

utbot-framework/src/test/java/org/utbot/examples/manual/examples/ArrayOfComplexArraysExample.java renamed to utbot-framework-test/src/main/java/org/utbot/examples/manual/examples/ArrayOfComplexArraysExample.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
package org.utbot.examples.manual.examples;
2+
23
import org.utbot.examples.assemble.arrays.ArrayOfComplexArrays;
34

45
public class ArrayOfComplexArraysExample {

utbot-framework/src/test/kotlin/org/utbot/engine/z3/ExtensionsKtTest.kt renamed to utbot-framework-test/src/test/kotlin/org/utbot/engine/z3/ExtensionsKtTest.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import org.junit.jupiter.api.assertThrows
1212
import org.junit.jupiter.params.ParameterizedTest
1313
import org.junit.jupiter.params.provider.Arguments.arguments
1414
import org.junit.jupiter.params.provider.MethodSource
15+
import org.utbot.engine.z3.ExtensionsKtTest.Companion.toSort
1516
import soot.BooleanType
1617
import soot.ByteType
1718
import soot.CharType

utbot-framework/src/test/kotlin/org/utbot/examples/algorithms/BinarySearchTest.kt renamed to utbot-framework-test/src/test/kotlin/org/utbot/examples/algorithms/BinarySearchTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package org.utbot.examples.algorithms
22

3-
import org.utbot.examples.UtValueTestCaseChecker
4-
import org.utbot.examples.ignoreExecutionsNumber
5-
import org.utbot.examples.isException
3+
import org.utbot.tests.infrastructure.UtValueTestCaseChecker
4+
import org.utbot.tests.infrastructure.ignoreExecutionsNumber
5+
import org.utbot.tests.infrastructure.isException
66
import org.utbot.framework.plugin.api.DocCodeStmt
77
import org.utbot.framework.plugin.api.DocPreTagStatement
88
import org.utbot.framework.plugin.api.DocRegularStmt

utbot-framework/src/test/kotlin/org/utbot/examples/algorithms/CorrectBracketSequencesTest.kt renamed to utbot-framework-test/src/test/kotlin/org/utbot/examples/algorithms/CorrectBracketSequencesTest.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
package org.utbot.examples.algorithms
22

3-
import org.utbot.examples.UtValueTestCaseChecker
3+
import org.utbot.tests.infrastructure.UtValueTestCaseChecker
44
import org.utbot.examples.algorithms.CorrectBracketSequences.isBracket
55
import org.utbot.examples.algorithms.CorrectBracketSequences.isOpen
6-
import org.utbot.examples.eq
7-
import org.utbot.examples.ignoreExecutionsNumber
8-
import org.utbot.examples.isException
9-
import org.utbot.examples.keyMatch
10-
import org.utbot.framework.codegen.CodeGeneration
6+
import org.utbot.tests.infrastructure.ignoreExecutionsNumber
7+
import org.utbot.tests.infrastructure.isException
8+
import org.utbot.tests.infrastructure.keyMatch
119
import org.utbot.framework.plugin.api.CodegenLanguage
1210
import org.utbot.framework.plugin.api.DocCodeStmt
1311
import org.utbot.framework.plugin.api.DocPreTagStatement
1412
import org.utbot.framework.plugin.api.DocRegularStmt
1513
import org.junit.jupiter.api.Test
14+
import org.utbot.testcheckers.eq
15+
import org.utbot.tests.infrastructure.CodeGeneration
1616

1717
internal class CorrectBracketSequencesTest : UtValueTestCaseChecker(
1818
testClass = CorrectBracketSequences::class,

utbot-framework/src/test/kotlin/org/utbot/examples/algorithms/GraphTest.kt renamed to utbot-framework-test/src/test/kotlin/org/utbot/examples/algorithms/GraphTest.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package org.utbot.examples.algorithms
22

3-
import org.utbot.examples.UtValueTestCaseChecker
4-
import org.utbot.examples.eq
5-
import org.utbot.examples.ignoreExecutionsNumber
6-
import org.utbot.examples.isException
3+
import org.utbot.tests.infrastructure.UtValueTestCaseChecker
4+
import org.utbot.tests.infrastructure.ignoreExecutionsNumber
5+
import org.utbot.tests.infrastructure.isException
76
import org.junit.jupiter.api.Tag
87
import org.junit.jupiter.api.Test
8+
import org.utbot.testcheckers.eq
99

1010
internal class GraphTest : UtValueTestCaseChecker(testClass = GraphExample::class) {
1111
@Test

utbot-framework/src/test/kotlin/org/utbot/examples/algorithms/SortTest.kt renamed to utbot-framework-test/src/test/kotlin/org/utbot/examples/algorithms/SortTest.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
package org.utbot.examples.algorithms
22

3-
import org.utbot.examples.UtValueTestCaseChecker
4-
import org.utbot.examples.eq
5-
import org.utbot.examples.ge
6-
import org.utbot.examples.ignoreExecutionsNumber
7-
import org.utbot.examples.isException
8-
import org.utbot.examples.keyMatch
3+
import org.utbot.tests.infrastructure.UtValueTestCaseChecker
4+
import org.utbot.tests.infrastructure.ignoreExecutionsNumber
5+
import org.utbot.tests.infrastructure.isException
6+
import org.utbot.tests.infrastructure.keyMatch
97
import org.utbot.framework.plugin.api.DocCodeStmt
108
import org.utbot.framework.plugin.api.DocPreTagStatement
119
import org.utbot.framework.plugin.api.DocRegularStmt
1210
import org.utbot.framework.plugin.api.MockStrategyApi
1311
import org.junit.jupiter.api.Test
12+
import org.utbot.testcheckers.eq
13+
import org.utbot.testcheckers.ge
1414

1515
internal class SortTest : UtValueTestCaseChecker(testClass = Sort::class) {
1616
@Test

0 commit comments

Comments
 (0)