|
| 1 | +package org.utbot.examples.threads |
| 2 | + |
| 3 | +import org.junit.jupiter.api.Test |
| 4 | +import org.utbot.testcheckers.withoutConcrete |
| 5 | +import org.utbot.testing.AtLeast |
| 6 | +import org.utbot.testing.UtValueTestCaseChecker |
| 7 | +import org.utbot.testing.ignoreExecutionsNumber |
| 8 | +import org.utbot.testing.isException |
| 9 | + |
| 10 | +// IMPORTANT: most of the these tests test only the symbolic engine |
| 11 | +// and should not be used for testing conrete or code generation since they are possibly flaky in the concrete execution |
| 12 | +// (see https://github.com/UnitTestBot/UTBotJava/issues/1610) |
| 13 | +class ThreadExamplesTest : UtValueTestCaseChecker(testClass = ThreadExamples::class) { |
| 14 | + @Test |
| 15 | + fun testExceptionInStart() { |
| 16 | + withoutConcrete { |
| 17 | + withEnabledTestingCodeGeneration(false) { |
| 18 | + checkWithException( |
| 19 | + ThreadExamples::explicitExceptionInStart, |
| 20 | + ignoreExecutionsNumber, |
| 21 | + { r -> r.isException<IllegalStateException>() } |
| 22 | + ) |
| 23 | + } |
| 24 | + } |
| 25 | + } |
| 26 | + |
| 27 | + @Test |
| 28 | + fun testChangingCollectionInThread() { |
| 29 | + withoutConcrete { |
| 30 | + withEnabledTestingCodeGeneration(false) { |
| 31 | + check( |
| 32 | + ThreadExamples::changingCollectionInThread, |
| 33 | + ignoreExecutionsNumber, |
| 34 | + { r -> r == 42 }, |
| 35 | + coverage = AtLeast(81) |
| 36 | + ) |
| 37 | + } |
| 38 | + } |
| 39 | + } |
| 40 | + |
| 41 | + @Test |
| 42 | + fun testChangingCollectionInThreadWithoutStart() { |
| 43 | + withoutConcrete { |
| 44 | + withEnabledTestingCodeGeneration(false) { |
| 45 | + checkWithException( |
| 46 | + ThreadExamples::changingCollectionInThreadWithoutStart, |
| 47 | + ignoreExecutionsNumber, |
| 48 | + { r -> r.isException<IndexOutOfBoundsException>() }, |
| 49 | + coverage = AtLeast(81) |
| 50 | + ) |
| 51 | + } |
| 52 | + } |
| 53 | + } |
| 54 | +} |
0 commit comments