Created
October 15, 2024 12:27
-
-
Save Andrew0000/0af304294f54b8142528c735bc48e40b to your computer and use it in GitHub Desktop.
Check gradle parallel test: same process (memory) or different?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tasks.withType<Test>().configureEach { | |
maxParallelForks = 3 | |
} | |
// Another File | |
object TestSharedObject { | |
@Volatile | |
var counter = 0 | |
} | |
// Another File | |
import org.junit.Assert | |
import org.junit.Test | |
class Test1 { | |
@Test | |
fun t1() { | |
TestSharedObject.counter = 1 | |
Thread.sleep(3000) | |
Assert.assertEquals(1, TestSharedObject.counter) | |
} | |
} | |
// Another File | |
import org.junit.Assert | |
import org.junit.Test | |
class Test2 { | |
@Test | |
fun t2() { | |
TestSharedObject.counter = 2 | |
Thread.sleep(3000) | |
Assert.assertEquals(2, TestSharedObject.counter) | |
} | |
} | |
// Another File | |
import org.junit.Assert | |
import org.junit.Test | |
class Test3 { | |
@Test | |
fun t3() { | |
TestSharedObject.counter = 3 | |
Thread.sleep(3000) | |
Assert.assertEquals(3, TestSharedObject.counter) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
p.s. don't look at 9 sec, it's 3 sec in total in reality