diff --git a/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/JunitTestRunner.java b/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/JunitTestRunner.java index 24c1b4847d7ac..20927d810aed1 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/JunitTestRunner.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/JunitTestRunner.java @@ -545,7 +545,7 @@ public String apply(Class aClass) { ClassWriter writer = new QuarkusClassWriter(cr, ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); cr.accept(new TestTracingProcessor.TracingClassVisitor(writer, i), 0); - transformedClasses.put(i, writer.toByteArray()); + transformedClasses.put(i.replace(".", "/") + ".class", writer.toByteArray()); } catch (IOException e) { throw new RuntimeException(e); } diff --git a/core/devmode-spi/src/main/java/io/quarkus/dev/console/BasicConsole.java b/core/devmode-spi/src/main/java/io/quarkus/dev/console/BasicConsole.java index b52386150fda7..893d97dc77c5b 100644 --- a/core/devmode-spi/src/main/java/io/quarkus/dev/console/BasicConsole.java +++ b/core/devmode-spi/src/main/java/io/quarkus/dev/console/BasicConsole.java @@ -11,6 +11,12 @@ public class BasicConsole extends QuarkusConsole { private static final Logger log = Logger.getLogger(BasicConsole.class.getName()); private static final Logger statusLogger = Logger.getLogger("quarkus"); + private static final ThreadLocal DISABLE_FILTER = new ThreadLocal<>() { + @Override + protected Boolean initialValue() { + return false; + } + }; final PrintStream printStream; final boolean inputSupport; final boolean noColor; @@ -57,7 +63,12 @@ protected void setPromptMessage(String prompt) { if (prompt == null) { return; } - statusLogger.info(prompt); + DISABLE_FILTER.set(true); + try { + statusLogger.info(prompt); + } finally { + DISABLE_FILTER.set(false); + } } @Override @@ -65,7 +76,12 @@ protected void setStatusMessage(String status) { if (status == null) { return; } - statusLogger.info(status); + DISABLE_FILTER.set(true); + try { + statusLogger.info(status); + } finally { + DISABLE_FILTER.set(false); + } } }; } @@ -74,7 +90,10 @@ protected void setStatusMessage(String status) { public void write(String s) { if (outputFilter != null) { if (!outputFilter.test(s)) { - return; + //we still test, the output filter may be recording output + if (!DISABLE_FILTER.get()) { + return; + } } } if (noColor || !hasColorSupport()) { diff --git a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/QuarkusTestTypeTestCase.java b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/QuarkusTestTypeTestCase.java index e4b84dfecf957..3ea092fa5510b 100644 --- a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/QuarkusTestTypeTestCase.java +++ b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/QuarkusTestTypeTestCase.java @@ -19,7 +19,7 @@ public class QuarkusTestTypeTestCase { .setArchiveProducer(new Supplier() { @Override public JavaArchive get() { - return ShrinkWrap.create(JavaArchive.class).addClass(HelloResource.class) + return ShrinkWrap.create(JavaArchive.class).addClasses(HelloResource.class, UnitService.class) .add(new StringAsset(ContinuousTestingTestUtils.appProperties("quarkus.test.type=quarkus-test")), "application.properties"); } diff --git a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/TestRunnerSmokeTestCase.java b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/TestRunnerSmokeTestCase.java index fa24daa273394..31dd6d101b7d2 100644 --- a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/TestRunnerSmokeTestCase.java +++ b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/TestRunnerSmokeTestCase.java @@ -23,7 +23,7 @@ public class TestRunnerSmokeTestCase { .setArchiveProducer(new Supplier() { @Override public JavaArchive get() { - return ShrinkWrap.create(JavaArchive.class).addClass(HelloResource.class) + return ShrinkWrap.create(JavaArchive.class).addClasses(HelloResource.class, UnitService.class) .add(new StringAsset(ContinuousTestingTestUtils.appProperties()), "application.properties"); } @@ -39,10 +39,10 @@ public JavaArchive get() { public void checkTestsAreRun() throws InterruptedException { TestStatus ts = ContinuousTestingTestUtils.waitForFirstRunToComplete(); Assertions.assertEquals(1L, ts.getLastRun()); - Assertions.assertEquals(2L, ts.getTestsFailed()); + Assertions.assertEquals(3L, ts.getTestsFailed()); Assertions.assertEquals(1L, ts.getTestsPassed()); Assertions.assertEquals(0L, ts.getTestsSkipped()); - Assertions.assertEquals(2L, ts.getTotalTestsFailed()); + Assertions.assertEquals(3L, ts.getTotalTestsFailed()); Assertions.assertEquals(1L, ts.getTotalTestsPassed()); Assertions.assertEquals(0L, ts.getTotalTestsSkipped()); Assertions.assertEquals(-1L, ts.getRunning()); @@ -55,7 +55,7 @@ public void checkTestsAreRun() throws InterruptedException { Assertions.assertEquals(1, cr.getFailing().size()); Assertions.assertEquals(1, cr.getPassing().size()); } else if (cr.getClassName().equals(UnitET.class.getName())) { - Assertions.assertEquals(1, cr.getFailing().size()); + Assertions.assertEquals(2, cr.getFailing().size()); Assertions.assertEquals(0, cr.getPassing().size()); } else { Assertions.fail("Unexpected test " + cr.getClassName()); @@ -71,58 +71,74 @@ public String apply(String s) { }); ts = ContinuousTestingTestUtils.waitForRun(2); Assertions.assertEquals(2L, ts.getLastRun()); - Assertions.assertEquals(1L, ts.getTestsFailed()); + Assertions.assertEquals(2L, ts.getTestsFailed()); Assertions.assertEquals(2L, ts.getTestsPassed()); Assertions.assertEquals(0L, ts.getTestsSkipped()); - Assertions.assertEquals(1L, ts.getTotalTestsFailed()); + Assertions.assertEquals(2L, ts.getTotalTestsFailed()); Assertions.assertEquals(2L, ts.getTotalTestsPassed()); Assertions.assertEquals(0L, ts.getTotalTestsSkipped()); Assertions.assertEquals(-1L, ts.getRunning()); //fix the unit test - test.modifyTestSourceFile(UnitET.class, new Function() { + test.modifySourceFile(UnitService.class, new Function() { @Override public String apply(String s) { - return s.replace("Hi", "hello"); + return s.replace("unit", "UNIT"); } }); ts = ContinuousTestingTestUtils.waitForRun(3); Assertions.assertEquals(3L, ts.getLastRun()); - Assertions.assertEquals(0L, ts.getTestsFailed()); + Assertions.assertEquals(1L, ts.getTestsFailed()); Assertions.assertEquals(1L, ts.getTestsPassed()); Assertions.assertEquals(0L, ts.getTestsSkipped()); - Assertions.assertEquals(0L, ts.getTotalTestsFailed()); + Assertions.assertEquals(1L, ts.getTotalTestsFailed()); Assertions.assertEquals(3L, ts.getTotalTestsPassed()); Assertions.assertEquals(0L, ts.getTotalTestsSkipped()); Assertions.assertEquals(-1L, ts.getRunning()); - //disable the unit test test.modifyTestSourceFile(UnitET.class, new Function() { @Override public String apply(String s) { - return s.replace("@Test", "@Test @org.junit.jupiter.api.Disabled"); + return s.replace("Hi", "hello"); } }); ts = ContinuousTestingTestUtils.waitForRun(4); Assertions.assertEquals(4L, ts.getLastRun()); Assertions.assertEquals(0L, ts.getTestsFailed()); + Assertions.assertEquals(2L, ts.getTestsPassed()); + Assertions.assertEquals(0L, ts.getTestsSkipped()); + Assertions.assertEquals(0L, ts.getTotalTestsFailed()); + Assertions.assertEquals(4L, ts.getTotalTestsPassed()); + Assertions.assertEquals(0L, ts.getTotalTestsSkipped()); + Assertions.assertEquals(-1L, ts.getRunning()); + + //disable the unit test + test.modifyTestSourceFile(UnitET.class, new Function() { + @Override + public String apply(String s) { + return s.replaceAll("@Test", "@Test @org.junit.jupiter.api.Disabled"); + } + }); + ts = ContinuousTestingTestUtils.waitForRun(5); + Assertions.assertEquals(5L, ts.getLastRun()); + Assertions.assertEquals(0L, ts.getTestsFailed()); Assertions.assertEquals(0L, ts.getTestsPassed()); - Assertions.assertEquals(1L, ts.getTestsSkipped()); + Assertions.assertEquals(2L, ts.getTestsSkipped()); Assertions.assertEquals(0L, ts.getTotalTestsFailed()); Assertions.assertEquals(2L, ts.getTotalTestsPassed()); - Assertions.assertEquals(1L, ts.getTotalTestsSkipped()); + Assertions.assertEquals(2L, ts.getTotalTestsSkipped()); Assertions.assertEquals(-1L, ts.getRunning()); //delete the unit test test.modifyTestSourceFile(UnitET.class, new Function() { @Override public String apply(String s) { - return s.replace("@Test", "//@Test"); + return s.replaceAll("@Test", "//@Test"); } }); - ts = ContinuousTestingTestUtils.waitForRun(5); - Assertions.assertEquals(5L, ts.getLastRun()); + ts = ContinuousTestingTestUtils.waitForRun(6); + Assertions.assertEquals(6L, ts.getLastRun()); Assertions.assertEquals(0L, ts.getTestsFailed()); Assertions.assertEquals(0L, ts.getTestsPassed()); Assertions.assertEquals(0L, ts.getTestsSkipped()); diff --git a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/UnitET.java b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/UnitET.java index 34dae4cd4f8ac..6569114771672 100644 --- a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/UnitET.java +++ b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/UnitET.java @@ -5,6 +5,11 @@ public class UnitET { + @Test + public void unitStyleTest2() { + Assertions.assertEquals("UNIT", UnitService.service()); + } + @Test public void unitStyleTest() { HelloResource res = new HelloResource(); diff --git a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/UnitService.java b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/UnitService.java new file mode 100644 index 0000000000000..f578657e9b0a9 --- /dev/null +++ b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/UnitService.java @@ -0,0 +1,9 @@ +package io.quarkus.vertx.http.testrunner; + +public class UnitService { + + public static String service() { + return "unit"; + } + +} diff --git a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/UnitTestTypeTestCase.java b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/UnitTestTypeTestCase.java index b607a6c6067a9..91bba374bff9a 100644 --- a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/UnitTestTypeTestCase.java +++ b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/UnitTestTypeTestCase.java @@ -19,7 +19,7 @@ public class UnitTestTypeTestCase { .setArchiveProducer(new Supplier() { @Override public JavaArchive get() { - return ShrinkWrap.create(JavaArchive.class).addClass(HelloResource.class) + return ShrinkWrap.create(JavaArchive.class).addClasses(HelloResource.class, UnitService.class) .add(new StringAsset(ContinuousTestingTestUtils.appProperties("quarkus.test.type=unit")), "application.properties"); } @@ -35,7 +35,7 @@ public JavaArchive get() { public void testUnitMode() throws InterruptedException { TestStatus ts = ContinuousTestingTestUtils.waitForFirstRunToComplete(); Assertions.assertEquals(1L, ts.getLastRun()); - Assertions.assertEquals(1L, ts.getTestsFailed()); + Assertions.assertEquals(2L, ts.getTestsFailed()); Assertions.assertEquals(0L, ts.getTestsPassed()); Assertions.assertEquals(0L, ts.getTestsSkipped()); Assertions.assertEquals(-1L, ts.getRunning());