Description
As seen in issue #2038 if a class level resource lock is specified, even if it is only a READ lock it will cause all tests that inherit it to run single threaded if any one of those tests uses a READ_WRITE lock. It was suggested in a comment by @leonard84 that it might be possible to add an annotation that would apply to a descriptor's children but not to the descriptor itself. This kind of functionality would be extremely useful in our project because we have 3000+ tests spread over hundreds of test classes. I would like to apply a READ lock to our commonly used resources in the inheritance chain rather than having to add individual resource locks on each of several thousand tests. However, if I do specify a class level/inherited lock of any kind it makes any class that inherits it run in SAME_THREAD mode if there is any READ_WRITE locks anywhere in the class.
In this below example the first two tests run in parallel and tests 3/4 run individually as expected. But if you uncomment the class level resource lock then all tests run individually. I would like there to be a way to specify that all of these tests have a READ lock on resource2 without having to add the lock individually to each test:
// @ResourceLock(value = "resource2", mode = READ)
public class SampleClassLevelLocksTest {
@Test
@ResourceLock(value = "resource1", mode = READ)
void test1() throws InterruptedException {
Thread.sleep(2000L);
Assertions.assertTrue(true);
}
@Test
@ResourceLock(value = "resource1", mode = READ)
void test2() throws InterruptedException {
Thread.sleep(2000L);
Assertions.assertTrue(true);
}
@Test
@ResourceLock(value = "resource1", mode = READ_WRITE)
void test3() throws InterruptedException {
Thread.sleep(2000L);
Assertions.assertTrue(true);
}
@Test
@ResourceLock(value = "resource1", mode = READ_WRITE)
void test4() throws InterruptedException {
Thread.sleep(2000L);
Assertions.assertTrue(true);
}
Deliverables
- Implement a way to specify resource locks that should be inherited to tests without forcing the tests to run in SAME_THREAD mode if there is a READ_WRITE lock anywhere at the same level
Metadata
Metadata
Assignees
Type
Projects
Status