forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new state-based method for deciding if tests should run in the sa…
…me classloader
- Loading branch information
1 parent
0d6a99e
commit 4da51b3
Showing
4 changed files
with
200 additions
and
48 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
82 changes: 82 additions & 0 deletions
82
test-framework/junit5/src/test/java/io/quarkus/test/junit/TestResourceUtilTest.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package io.quarkus.test.junit; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotEquals; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import io.quarkus.test.common.QuarkusTestResourceLifecycleManager; | ||
|
||
public class TestResourceUtilTest { | ||
|
||
// Basic sense check, since most of the heavy lifting is done by TestResourceManager#getReloadGroupIdentifier | ||
@Test | ||
public void testReloadGroupIdentifierIsEqualForTestsWithNoResources() { | ||
String identifier1 = TestResourceUtil.getReloadGroupIdentifier(TestClass.class, ProfileClass.class); | ||
String identifier2 = TestResourceUtil.getReloadGroupIdentifier(TestClass.class, AnotherProfileClass.class); | ||
assertEquals(identifier2, identifier1); | ||
} | ||
|
||
@Test | ||
public void testReloadGroupIdentifierIsEqualForTestsWithIdenticalResources() { | ||
String identifier1 = TestResourceUtil.getReloadGroupIdentifier(TestClass.class, ProfileClassWithResources.class); | ||
String identifier2 = TestResourceUtil.getReloadGroupIdentifier(TestClass.class, AnotherProfileClassWithResources.class); | ||
assertEquals(identifier2, identifier1); | ||
} | ||
|
||
@Test | ||
public void testReloadGroupIdentifierIsEqualForTestsWithDifferentResources() { | ||
String identifier1 = TestResourceUtil.getReloadGroupIdentifier(TestClass.class, ProfileClassWithResources.class); | ||
String identifier2 = TestResourceUtil.getReloadGroupIdentifier(TestClass.class, ProfileClass.class); | ||
assertNotEquals(identifier2, identifier1); | ||
} | ||
} | ||
|
||
class TestClass { | ||
|
||
} | ||
|
||
class ProfileClass implements QuarkusTestProfile { | ||
|
||
public ProfileClass() { | ||
} | ||
} | ||
|
||
class AnotherProfileClass implements QuarkusTestProfile { | ||
|
||
public AnotherProfileClass() { | ||
} | ||
} | ||
|
||
class ProfileClassWithResources implements QuarkusTestProfile { | ||
|
||
public ProfileClassWithResources() { | ||
} | ||
|
||
@Override | ||
public List<TestResourceEntry> testResources() { | ||
return Collections.singletonList( | ||
new TestResourceEntry( | ||
Dummy.class, Map.of())); | ||
} | ||
} | ||
|
||
class AnotherProfileClassWithResources implements QuarkusTestProfile { | ||
|
||
public AnotherProfileClassWithResources() { | ||
} | ||
|
||
@Override | ||
public List<TestResourceEntry> testResources() { | ||
return Collections.singletonList( | ||
new TestResourceEntry( | ||
Dummy.class, Map.of())); | ||
} | ||
} | ||
|
||
abstract class Dummy implements QuarkusTestResourceLifecycleManager { | ||
} |