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.
Compile application classes before test classes
Fixes quarkusio#28376
- Loading branch information
1 parent
5aa3f11
commit 868a4c9
Showing
5 changed files
with
99 additions
and
1 deletion.
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
64 changes: 64 additions & 0 deletions
64
...ent/src/test/java/io/quarkus/vertx/http/testrunner/ChangeSourceAndTestAtOnceTestCase.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,64 @@ | ||
package io.quarkus.vertx.http.testrunner; | ||
|
||
import java.util.function.Function; | ||
import java.util.function.Supplier; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.dev.testing.TestScanningLock; | ||
import io.quarkus.test.ContinuousTestingTestUtils; | ||
import io.quarkus.test.ContinuousTestingTestUtils.TestStatus; | ||
import io.quarkus.test.QuarkusDevModeTest; | ||
|
||
public class ChangeSourceAndTestAtOnceTestCase { | ||
|
||
@RegisterExtension | ||
static QuarkusDevModeTest test = new QuarkusDevModeTest() | ||
.setArchiveProducer(new Supplier<>() { | ||
@Override | ||
public JavaArchive get() { | ||
return ShrinkWrap.create(JavaArchive.class).addClasses(CoupledService.class) | ||
.add(new StringAsset(ContinuousTestingTestUtils.appProperties("quarkus.test.type=unit")), | ||
"application.properties"); | ||
} | ||
}) | ||
.setTestArchiveProducer(new Supplier<>() { | ||
@Override | ||
public JavaArchive get() { | ||
return ShrinkWrap.create(JavaArchive.class).addClasses(CoupledET.class); | ||
} | ||
}); | ||
|
||
@Test | ||
public void testChangeSourceAndTestAtOnce() throws InterruptedException { | ||
ContinuousTestingTestUtils utils = new ContinuousTestingTestUtils(); | ||
TestStatus ts = utils.waitForNextCompletion(); | ||
Assertions.assertEquals(1L, ts.getTestsPassed()); | ||
TestScanningLock.lockForTests(); | ||
try { | ||
test.modifySourceFile(CoupledService.class, new Function<String, String>() { | ||
@Override | ||
public String apply(String s) { | ||
return s.replace("service", "newService"); | ||
} | ||
}); | ||
test.modifyTestSourceFile(CoupledET.class, new Function<String, String>() { | ||
@Override | ||
public String apply(String s) { | ||
return s.replace("service", "newService"); | ||
} | ||
}); | ||
|
||
} finally { | ||
TestScanningLock.unlockForTests(); | ||
} | ||
ts = utils.waitForNextCompletion(); | ||
Assertions.assertEquals(1L, ts.getTestsPassed()); | ||
|
||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...sions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/CoupledET.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,13 @@ | ||
package io.quarkus.vertx.http.testrunner; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class CoupledET { | ||
|
||
@Test | ||
public void unitStyleTest2() { | ||
Assertions.assertEquals("unit", CoupledService.service()); | ||
} | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
.../vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/CoupledService.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,9 @@ | ||
package io.quarkus.vertx.http.testrunner; | ||
|
||
public class CoupledService { | ||
|
||
public static String service() { | ||
return "unit"; | ||
} | ||
|
||
} |
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