|
| 1 | +package org.utbot.examples.stdlib |
| 2 | + |
| 3 | +import org.junit.jupiter.api.Disabled |
| 4 | +import org.junit.jupiter.api.Test |
| 5 | +import org.utbot.framework.plugin.api.CodegenLanguage |
| 6 | +import org.utbot.framework.plugin.api.util.id |
| 7 | +import org.utbot.testcheckers.ge |
| 8 | +import org.utbot.testing.FullWithAssumptions |
| 9 | +import org.utbot.testing.UtValueTestCaseChecker |
| 10 | +import java.io.File |
| 11 | + |
| 12 | +internal class StaticsPathDiversionTest : UtValueTestCaseChecker( |
| 13 | + testClass = StaticsPathDiversion::class, |
| 14 | + testCodeGeneration = true, |
| 15 | + pipelines = listOf( |
| 16 | + TestLastStage(CodegenLanguage.JAVA), |
| 17 | + TestLastStage(CodegenLanguage.KOTLIN) |
| 18 | + ) |
| 19 | +) { |
| 20 | + @Test |
| 21 | + @Disabled("See https://github.com/UnitTestBot/UTBotJava/issues/716") |
| 22 | + fun testJavaIOFile() { |
| 23 | + // TODO Here we have a path diversion example - the static field `java.io.File#separator` is considered as not meaningful, |
| 24 | + // so it is not passed to the concrete execution because of absence in the `stateBefore` models. |
| 25 | + // So, the symbolic engine has 2 results - true and false, as expected, but the concrete executor may produce 1 or 2, |
| 26 | + // depending on the model for the argument of the MUT produced by the solver. |
| 27 | + // Such diversion was predicted to some extent - see `org.utbot.common.WorkaroundReason.IGNORE_STATICS_FROM_TRUSTED_LIBRARIES` |
| 28 | + // and the corresponding issue https://github.com/UnitTestBot/UTBotJava/issues/716 |
| 29 | + check( |
| 30 | + StaticsPathDiversion::separatorEquality, |
| 31 | + ge(2), // We cannot guarantee the exact number of branches without minimization |
| 32 | + |
| 33 | + // In the matchers below we check that the symbolic does not change the static field `File.separator` - we should |
| 34 | + // change the parameter, not the static field |
| 35 | + { s, separator -> separator == File.separator && s == separator }, |
| 36 | + { s, separator -> separator == File.separator && s != separator }, |
| 37 | + additionalMockAlwaysClasses = setOf(java.io.File::class.id), // From the use-case |
| 38 | + coverage = FullWithAssumptions(assumeCallsNumber = 1) |
| 39 | + ) |
| 40 | + } |
| 41 | +} |
0 commit comments