forked from diffplug/selfie
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUT_ConcurrencyStressTest.kt
More file actions
27 lines (24 loc) · 933 Bytes
/
UT_ConcurrencyStressTest.kt
File metadata and controls
27 lines (24 loc) · 933 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package undertest.junit5
import com.diffplug.selfie.Selfie.expectSelfie
import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit
import kotlin.streams.asStream
import org.junit.jupiter.api.DynamicTest.dynamicTest
import org.junit.jupiter.api.TestFactory
import org.junit.jupiter.api.parallel.Execution
import org.junit.jupiter.api.parallel.ExecutionMode
@Execution(ExecutionMode.CONCURRENT)
class UT_ConcurrencyStressTest {
// sanity check: make sure our junit-platform.properties file is getting picked up
private val latch = CountDownLatch(8)
@TestFactory
fun testFactory() =
(1..1000).asSequence().asStream().map { digit ->
dynamicTest(String.format("%04d", digit)) {
latch.countDown()
latch.await(5, TimeUnit.SECONDS)
println(Thread.currentThread())
expectSelfie(digit.toString()).toMatchDisk(String.format("%04d", digit))
}
}
}