diff --git a/devtools/maven/src/main/java/io/quarkus/maven/CreateExtensionMojo.java b/devtools/maven/src/main/java/io/quarkus/maven/CreateExtensionMojo.java index 3989ab804d7a4..e3ecc9cdecdac 100644 --- a/devtools/maven/src/main/java/io/quarkus/maven/CreateExtensionMojo.java +++ b/devtools/maven/src/main/java/io/quarkus/maven/CreateExtensionMojo.java @@ -513,6 +513,22 @@ public class CreateExtensionMojo extends AbstractMojo { @Parameter(defaultValue = COMPILER_PLUGIN_DEFAULT_VERSION, required = true, property = "quarkus.mavenCompilerPluginVersion") String compilerPluginVersion; + /** + * Indicates whether to generate a unit test class for the extension + * + * @since 1.3.0 + */ + @Parameter(property = "quarkus.generateUnitTest", defaultValue = "true") + boolean generateUnitTest; + + /** + * Indicates whether to generate a dev mode unit test class for the extension + * + * @since 1.3.0 + */ + @Parameter(property = "quarkus.generateDevModeTest", defaultValue = "true") + boolean generateDevModeTest; + boolean currentProjectIsBaseDir; Charset charset; @@ -825,6 +841,14 @@ private void generateExtensionProjects(Configuration cfg, TemplateParams templat .resolve("deployment") .resolve(templateParams.artifactIdBaseCamelCase + "Processor.java"); evalTemplate(cfg, "Processor.java", processorPath, templateParams); + + if (generateUnitTest) { + generateUnitTestClass(cfg, templateParams); + } + + if (generateDevModeTest) { + generateDevModeTestClass(cfg, templateParams); + } } private PomTransformer pomTransformer(Path basePomXml) { @@ -905,6 +929,24 @@ private Configuration getTemplateConfig() throws IOException { return templateCfg; } + private void generateUnitTestClass(Configuration cfg, TemplateParams model) throws IOException, TemplateException { + final Path unitTest = basedir.toPath() + .resolve(model.artifactIdBase + "/deployment/src/test/java/" + model.javaPackageBase.replace('.', '/') + + "/test/" + model.artifactIdBaseCamelCase + "Test.java"); + + evalTemplate(cfg, "UnitTest.java", unitTest, model); + } + + private void generateDevModeTestClass(Configuration cfg, TemplateParams model) throws IOException, TemplateException { + final Path devModeTest = basedir + .toPath() + .resolve(model.artifactIdBase + "/deployment/src/test/java/" + model.javaPackageBase.replace('.', '/') + + "/test/" + model.artifactIdBaseCamelCase + "DevModeTest.java"); + + evalTemplate(cfg, "DevModeTest.java", devModeTest, model); + + } + void generateItest(Configuration cfg, TemplateParams model) throws MojoFailureException, MojoExecutionException, TemplateException, IOException { final Path itestParentAbsPath = basedir.toPath().resolve(itestParentPath); diff --git a/devtools/maven/src/main/resources/create-extension-templates/DevModeTest.java b/devtools/maven/src/main/resources/create-extension-templates/DevModeTest.java new file mode 100644 index 0000000000000..10a0eaabb287f --- /dev/null +++ b/devtools/maven/src/main/resources/create-extension-templates/DevModeTest.java @@ -0,0 +1,22 @@ +package [=javaPackageBase].test; + +import org.jboss.shrinkwrap.api.ShrinkWrap; +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.test.QuarkusDevModeTest; + +class [=artifactIdBaseCamelCase]DevModeTest { + @RegisterExtension + static final QuarkusDevModeTest devModeTest = new QuarkusDevModeTest() // Start hot reload (DevMode) test with your extension loaded + .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)); + + @Test + public void test() { + // Write your tests here - see the testing extension guide https://quarkus.io/guides/writing-extensions#testing-hot-reload for more information + Assertions.fail("Add dev mode assertions to " + getClass().getName()); + } + +} diff --git a/devtools/maven/src/main/resources/create-extension-templates/UnitTest.java b/devtools/maven/src/main/resources/create-extension-templates/UnitTest.java new file mode 100644 index 0000000000000..67c7dc6d47196 --- /dev/null +++ b/devtools/maven/src/main/resources/create-extension-templates/UnitTest.java @@ -0,0 +1,23 @@ +package [=javaPackageBase].test; + +import org.jboss.shrinkwrap.api.ShrinkWrap; +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.test.QuarkusUnitTest; + +class [=artifactIdBaseCamelCase]Test { + + @RegisterExtension + static final QuarkusUnitTest unitTest = new QuarkusUnitTest() // Start unit test with your extension loaded + .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)); + + @Test + public void test() { + // Write your tests here - see the testing extension guide https://quarkus.io/guides/writing-extensions#testing-extensions for more information + Assertions.fail("Add some assertions to " + getClass().getName()); + } + +} diff --git a/devtools/maven/src/main/resources/create-extension-templates/deployment-pom.xml b/devtools/maven/src/main/resources/create-extension-templates/deployment-pom.xml index b98ab19f868ab..0750743c84ba9 100644 --- a/devtools/maven/src/main/resources/create-extension-templates/deployment-pom.xml +++ b/devtools/maven/src/main/resources/create-extension-templates/deployment-pom.xml @@ -25,6 +25,11 @@ [#if !assumeManaged ] [=r"$"]{project.version} [/#if] + + io.quarkus + quarkus-junit5-internal + test + diff --git a/integration-tests/maven/src/test/java/io/quarkus/maven/CreateExtensionMojoTest.java b/integration-tests/maven/src/test/java/io/quarkus/maven/CreateExtensionMojoTest.java index 0652021e82e75..e3705e9a74429 100644 --- a/integration-tests/maven/src/test/java/io/quarkus/maven/CreateExtensionMojoTest.java +++ b/integration-tests/maven/src/test/java/io/quarkus/maven/CreateExtensionMojoTest.java @@ -34,6 +34,8 @@ private static CreateExtensionMojo initMojo(final Path projectDir) throws IOExce final CreateExtensionMojo mojo = new CreateExtensionMojo(); mojo.project = new MavenProject(); mojo.basedir = projectDir.toFile(); + mojo.generateDevModeTest = true; + mojo.generateUnitTest = true; final File pom = new File(projectDir.toFile(), "pom.xml"); if (pom.exists()) { @@ -125,7 +127,7 @@ private static Path newProjectDir(String testProjectName) throws IOException { @Test void createExtensionUnderExistingPomMinimal() throws MojoExecutionException, MojoFailureException, - IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException, IOException { + IllegalArgumentException, SecurityException, IOException { final CreateExtensionMojo mojo = initMojo(createProjectFromTemplate("create-extension-pom")); mojo.artifactId = "my-project-(minimal-extension)"; mojo.assumeManaged = false; @@ -137,7 +139,7 @@ void createExtensionUnderExistingPomMinimal() throws MojoExecutionException, Moj @Test void createExtensionUnderExistingPomWithAdditionalRuntimeDependencies() throws MojoExecutionException, MojoFailureException, - IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException, IOException { + IllegalArgumentException, SecurityException, IOException { final CreateExtensionMojo mojo = initMojo(createProjectFromTemplate("create-extension-pom")); mojo.artifactId = "my-project-(add-to-bom)"; mojo.assumeManaged = false; @@ -152,7 +154,7 @@ void createExtensionUnderExistingPomWithAdditionalRuntimeDependencies() throws M @Test void createExtensionUnderExistingPomWithItest() throws MojoExecutionException, MojoFailureException, - IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException, IOException { + IllegalArgumentException, SecurityException, IOException { final CreateExtensionMojo mojo = initMojo(createProjectFromTemplate("create-extension-pom")); mojo.artifactId = "my-project-(itest)"; mojo.assumeManaged = false; @@ -165,7 +167,7 @@ void createExtensionUnderExistingPomWithItest() throws MojoExecutionException, M @Test void createExtensionUnderExistingPomCustomGrandParent() throws MojoExecutionException, MojoFailureException, - IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException, IOException { + IllegalArgumentException, SecurityException, IOException { final CreateExtensionMojo mojo = initMojo(createProjectFromTemplate("create-extension-pom")); mojo.artifactId = "myproject-(with-grand-parent)"; mojo.parentArtifactId = "grand-parent"; @@ -241,7 +243,7 @@ static void assertTreesMatch(Path expected, Path actual) throws IOException { } @Test - void getPackage() throws IOException { + void getPackage() { assertEquals("org.apache.camel.quarkus.aws.sns.deployment", CreateExtensionMojo .getJavaPackage("org.apache.camel.quarkus", null, "camel-quarkus-aws-sns-deployment")); assertEquals("org.apache.camel.quarkus.component.aws.sns.deployment", CreateExtensionMojo @@ -249,7 +251,7 @@ void getPackage() throws IOException { } @Test - void toCapCamelCase() throws IOException { + void toCapCamelCase() { assertEquals("FooBarBaz", CreateExtensionMojo.toCapCamelCase("foo-bar-baz")); } diff --git a/integration-tests/maven/src/test/resources/expected/create-extension-pom-add-to-bom/add-to-bom/deployment/pom.xml b/integration-tests/maven/src/test/resources/expected/create-extension-pom-add-to-bom/add-to-bom/deployment/pom.xml index 7addb97771c1e..fa56ac1dcad9a 100644 --- a/integration-tests/maven/src/test/resources/expected/create-extension-pom-add-to-bom/add-to-bom/deployment/pom.xml +++ b/integration-tests/maven/src/test/resources/expected/create-extension-pom-add-to-bom/add-to-bom/deployment/pom.xml @@ -23,6 +23,11 @@ my-project-add-to-bom ${project.version} + + io.quarkus + quarkus-junit5-internal + test + diff --git a/integration-tests/maven/src/test/resources/expected/create-extension-pom-add-to-bom/add-to-bom/deployment/src/test/java/org/acme/my/project/add/to/bom/test/AddToBomDevModeTest.java b/integration-tests/maven/src/test/resources/expected/create-extension-pom-add-to-bom/add-to-bom/deployment/src/test/java/org/acme/my/project/add/to/bom/test/AddToBomDevModeTest.java new file mode 100644 index 0000000000000..36edbcfa75b64 --- /dev/null +++ b/integration-tests/maven/src/test/resources/expected/create-extension-pom-add-to-bom/add-to-bom/deployment/src/test/java/org/acme/my/project/add/to/bom/test/AddToBomDevModeTest.java @@ -0,0 +1,22 @@ +package org.acme.my.project.add.to.bom.test; + +import org.jboss.shrinkwrap.api.ShrinkWrap; +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.test.QuarkusDevModeTest; + +class AddToBomDevModeTest { + @RegisterExtension + static final QuarkusDevModeTest devModeTest = new QuarkusDevModeTest() // Start hot reload (DevMode) test with your extension loaded + .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)); + + @Test + public void test() { + // Write your tests here - see the testing extension guide https://quarkus.io/guides/writing-extensions#testing-hot-reload for more information + Assertions.fail("Add dev mode assertions to " + getClass().getName()); + } + +} diff --git a/integration-tests/maven/src/test/resources/expected/create-extension-pom-add-to-bom/add-to-bom/deployment/src/test/java/org/acme/my/project/add/to/bom/test/AddToBomTest.java b/integration-tests/maven/src/test/resources/expected/create-extension-pom-add-to-bom/add-to-bom/deployment/src/test/java/org/acme/my/project/add/to/bom/test/AddToBomTest.java new file mode 100644 index 0000000000000..db18f37a01516 --- /dev/null +++ b/integration-tests/maven/src/test/resources/expected/create-extension-pom-add-to-bom/add-to-bom/deployment/src/test/java/org/acme/my/project/add/to/bom/test/AddToBomTest.java @@ -0,0 +1,23 @@ +package org.acme.my.project.add.to.bom.test; + +import org.jboss.shrinkwrap.api.ShrinkWrap; +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.test.QuarkusUnitTest; + +class AddToBomTest { + + @RegisterExtension + static final QuarkusUnitTest unitTest = new QuarkusUnitTest() // Start unit test with your extension loaded + .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)); + + @Test + public void test() { + // Write your tests here - see the testing extension guide https://quarkus.io/guides/writing-extensions#testing-extensions for more information + Assertions.fail("Add some assertions to " + getClass().getName()); + } + +} diff --git a/integration-tests/maven/src/test/resources/expected/create-extension-pom-itest/itest/deployment/pom.xml b/integration-tests/maven/src/test/resources/expected/create-extension-pom-itest/itest/deployment/pom.xml index d5c94a8c44610..ce4be68dadac5 100644 --- a/integration-tests/maven/src/test/resources/expected/create-extension-pom-itest/itest/deployment/pom.xml +++ b/integration-tests/maven/src/test/resources/expected/create-extension-pom-itest/itest/deployment/pom.xml @@ -23,6 +23,11 @@ my-project-itest ${project.version} + + io.quarkus + quarkus-junit5-internal + test + diff --git a/integration-tests/maven/src/test/resources/expected/create-extension-pom-itest/itest/deployment/src/test/java/org/acme/my/project/itest/test/ItestDevModeTest.java b/integration-tests/maven/src/test/resources/expected/create-extension-pom-itest/itest/deployment/src/test/java/org/acme/my/project/itest/test/ItestDevModeTest.java new file mode 100644 index 0000000000000..ce6f909b56702 --- /dev/null +++ b/integration-tests/maven/src/test/resources/expected/create-extension-pom-itest/itest/deployment/src/test/java/org/acme/my/project/itest/test/ItestDevModeTest.java @@ -0,0 +1,22 @@ +package org.acme.my.project.itest.test; + +import org.jboss.shrinkwrap.api.ShrinkWrap; +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.test.QuarkusDevModeTest; + +class ItestDevModeTest { + @RegisterExtension + static final QuarkusDevModeTest devModeTest = new QuarkusDevModeTest() // Start hot reload (DevMode) test with your extension loaded + .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)); + + @Test + public void test() { + // Write your tests here - see the testing extension guide https://quarkus.io/guides/writing-extensions#testing-hot-reload for more information + Assertions.fail("Add dev mode assertions to " + getClass().getName()); + } + +} diff --git a/integration-tests/maven/src/test/resources/expected/create-extension-pom-itest/itest/deployment/src/test/java/org/acme/my/project/itest/test/ItestTest.java b/integration-tests/maven/src/test/resources/expected/create-extension-pom-itest/itest/deployment/src/test/java/org/acme/my/project/itest/test/ItestTest.java new file mode 100644 index 0000000000000..e360eb2280e9b --- /dev/null +++ b/integration-tests/maven/src/test/resources/expected/create-extension-pom-itest/itest/deployment/src/test/java/org/acme/my/project/itest/test/ItestTest.java @@ -0,0 +1,23 @@ +package org.acme.my.project.itest.test; + +import org.jboss.shrinkwrap.api.ShrinkWrap; +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.test.QuarkusUnitTest; + +class ItestTest { + + @RegisterExtension + static final QuarkusUnitTest unitTest = new QuarkusUnitTest() // Start unit test with your extension loaded + .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)); + + @Test + public void test() { + // Write your tests here - see the testing extension guide https://quarkus.io/guides/writing-extensions#testing-extensions for more information + Assertions.fail("Add some assertions to " + getClass().getName()); + } + +} diff --git a/integration-tests/maven/src/test/resources/expected/create-extension-pom-minimal/minimal-extension/deployment/pom.xml b/integration-tests/maven/src/test/resources/expected/create-extension-pom-minimal/minimal-extension/deployment/pom.xml index 78ec5cab8eb8c..931dbb24fe833 100644 --- a/integration-tests/maven/src/test/resources/expected/create-extension-pom-minimal/minimal-extension/deployment/pom.xml +++ b/integration-tests/maven/src/test/resources/expected/create-extension-pom-minimal/minimal-extension/deployment/pom.xml @@ -23,6 +23,11 @@ my-project-minimal-extension ${project.version} + + io.quarkus + quarkus-junit5-internal + test + diff --git a/integration-tests/maven/src/test/resources/expected/create-extension-pom-minimal/minimal-extension/deployment/src/test/java/org/acme/my/project/minimal/extension/test/MinimalExtensionDevModeTest.java b/integration-tests/maven/src/test/resources/expected/create-extension-pom-minimal/minimal-extension/deployment/src/test/java/org/acme/my/project/minimal/extension/test/MinimalExtensionDevModeTest.java new file mode 100644 index 0000000000000..16ad0c524871d --- /dev/null +++ b/integration-tests/maven/src/test/resources/expected/create-extension-pom-minimal/minimal-extension/deployment/src/test/java/org/acme/my/project/minimal/extension/test/MinimalExtensionDevModeTest.java @@ -0,0 +1,22 @@ +package org.acme.my.project.minimal.extension.test; + +import org.jboss.shrinkwrap.api.ShrinkWrap; +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.test.QuarkusDevModeTest; + +class MinimalExtensionDevModeTest { + @RegisterExtension + static final QuarkusDevModeTest devModeTest = new QuarkusDevModeTest() // Start hot reload (DevMode) test with your extension loaded + .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)); + + @Test + public void test() { + // Write your tests here - see the testing extension guide https://quarkus.io/guides/writing-extensions#testing-hot-reload for more information + Assertions.fail("Add dev mode assertions to " + getClass().getName()); + } + +} diff --git a/integration-tests/maven/src/test/resources/expected/create-extension-pom-minimal/minimal-extension/deployment/src/test/java/org/acme/my/project/minimal/extension/test/MinimalExtensionTest.java b/integration-tests/maven/src/test/resources/expected/create-extension-pom-minimal/minimal-extension/deployment/src/test/java/org/acme/my/project/minimal/extension/test/MinimalExtensionTest.java new file mode 100644 index 0000000000000..3d93606a05ef4 --- /dev/null +++ b/integration-tests/maven/src/test/resources/expected/create-extension-pom-minimal/minimal-extension/deployment/src/test/java/org/acme/my/project/minimal/extension/test/MinimalExtensionTest.java @@ -0,0 +1,23 @@ +package org.acme.my.project.minimal.extension.test; + +import org.jboss.shrinkwrap.api.ShrinkWrap; +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.test.QuarkusUnitTest; + +class MinimalExtensionTest { + + @RegisterExtension + static final QuarkusUnitTest unitTest = new QuarkusUnitTest() // Start unit test with your extension loaded + .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)); + + @Test + public void test() { + // Write your tests here - see the testing extension guide https://quarkus.io/guides/writing-extensions#testing-extensions for more information + Assertions.fail("Add some assertions to " + getClass().getName()); + } + +} diff --git a/integration-tests/maven/src/test/resources/expected/create-extension-pom-with-grand-parent/with-grand-parent/deployment/pom.xml b/integration-tests/maven/src/test/resources/expected/create-extension-pom-with-grand-parent/with-grand-parent/deployment/pom.xml index 217c13e781115..a85d566741f13 100644 --- a/integration-tests/maven/src/test/resources/expected/create-extension-pom-with-grand-parent/with-grand-parent/deployment/pom.xml +++ b/integration-tests/maven/src/test/resources/expected/create-extension-pom-with-grand-parent/with-grand-parent/deployment/pom.xml @@ -22,6 +22,11 @@ org.acme myproject-with-grand-parent + + io.quarkus + quarkus-junit5-internal + test + diff --git a/integration-tests/maven/src/test/resources/expected/create-extension-pom-with-grand-parent/with-grand-parent/deployment/src/test/java/org/acme/myproject/with/grand/parent/test/WithGrandParentDevModeTest.java b/integration-tests/maven/src/test/resources/expected/create-extension-pom-with-grand-parent/with-grand-parent/deployment/src/test/java/org/acme/myproject/with/grand/parent/test/WithGrandParentDevModeTest.java new file mode 100644 index 0000000000000..28366191262e0 --- /dev/null +++ b/integration-tests/maven/src/test/resources/expected/create-extension-pom-with-grand-parent/with-grand-parent/deployment/src/test/java/org/acme/myproject/with/grand/parent/test/WithGrandParentDevModeTest.java @@ -0,0 +1,22 @@ +package org.acme.myproject.with.grand.parent.test; + +import org.jboss.shrinkwrap.api.ShrinkWrap; +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.test.QuarkusDevModeTest; + +class WithGrandParentDevModeTest { + @RegisterExtension + static final QuarkusDevModeTest devModeTest = new QuarkusDevModeTest() // Start hot reload (DevMode) test with your extension loaded + .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)); + + @Test + public void test() { + // Write your tests here - see the testing extension guide https://quarkus.io/guides/writing-extensions#testing-hot-reload for more information + Assertions.fail("Add dev mode assertions to " + getClass().getName()); + } + +} diff --git a/integration-tests/maven/src/test/resources/expected/create-extension-pom-with-grand-parent/with-grand-parent/deployment/src/test/java/org/acme/myproject/with/grand/parent/test/WithGrandParentTest.java b/integration-tests/maven/src/test/resources/expected/create-extension-pom-with-grand-parent/with-grand-parent/deployment/src/test/java/org/acme/myproject/with/grand/parent/test/WithGrandParentTest.java new file mode 100644 index 0000000000000..11a4d78fbd353 --- /dev/null +++ b/integration-tests/maven/src/test/resources/expected/create-extension-pom-with-grand-parent/with-grand-parent/deployment/src/test/java/org/acme/myproject/with/grand/parent/test/WithGrandParentTest.java @@ -0,0 +1,23 @@ +package org.acme.myproject.with.grand.parent.test; + +import org.jboss.shrinkwrap.api.ShrinkWrap; +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.test.QuarkusUnitTest; + +class WithGrandParentTest { + + @RegisterExtension + static final QuarkusUnitTest unitTest = new QuarkusUnitTest() // Start unit test with your extension loaded + .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)); + + @Test + public void test() { + // Write your tests here - see the testing extension guide https://quarkus.io/guides/writing-extensions#testing-extensions for more information + Assertions.fail("Add some assertions to " + getClass().getName()); + } + +} diff --git a/integration-tests/maven/src/test/resources/expected/new-extension-project/my-ext/deployment/pom.xml b/integration-tests/maven/src/test/resources/expected/new-extension-project/my-ext/deployment/pom.xml index 6ee59f6e8843f..9650c557d75f0 100644 --- a/integration-tests/maven/src/test/resources/expected/new-extension-project/my-ext/deployment/pom.xml +++ b/integration-tests/maven/src/test/resources/expected/new-extension-project/my-ext/deployment/pom.xml @@ -23,6 +23,11 @@ my-ext \${project.version} + + io.quarkus + quarkus-junit5-internal + test + diff --git a/integration-tests/maven/src/test/resources/expected/new-extension-project/my-ext/deployment/src/test/java/org/acme/my/ext/test/MyExtDevModeTest.java b/integration-tests/maven/src/test/resources/expected/new-extension-project/my-ext/deployment/src/test/java/org/acme/my/ext/test/MyExtDevModeTest.java new file mode 100644 index 0000000000000..6132fc535f323 --- /dev/null +++ b/integration-tests/maven/src/test/resources/expected/new-extension-project/my-ext/deployment/src/test/java/org/acme/my/ext/test/MyExtDevModeTest.java @@ -0,0 +1,22 @@ +package org.acme.my.ext.test; + +import org.jboss.shrinkwrap.api.ShrinkWrap; +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.test.QuarkusDevModeTest; + +class MyExtDevModeTest { + @RegisterExtension + static final QuarkusDevModeTest devModeTest = new QuarkusDevModeTest() // Start hot reload (DevMode) test with your extension loaded + .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)); + + @Test + public void test() { + // Write your tests here - see the testing extension guide https://quarkus.io/guides/writing-extensions#testing-hot-reload for more information + Assertions.fail("Add dev mode assertions to " + getClass().getName()); + } + +} diff --git a/integration-tests/maven/src/test/resources/expected/new-extension-project/my-ext/deployment/src/test/java/org/acme/my/ext/test/MyExtTest.java b/integration-tests/maven/src/test/resources/expected/new-extension-project/my-ext/deployment/src/test/java/org/acme/my/ext/test/MyExtTest.java new file mode 100644 index 0000000000000..71ed95323e1d2 --- /dev/null +++ b/integration-tests/maven/src/test/resources/expected/new-extension-project/my-ext/deployment/src/test/java/org/acme/my/ext/test/MyExtTest.java @@ -0,0 +1,23 @@ +package org.acme.my.ext.test; + +import org.jboss.shrinkwrap.api.ShrinkWrap; +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.test.QuarkusUnitTest; + +class MyExtTest { + + @RegisterExtension + static final QuarkusUnitTest unitTest = new QuarkusUnitTest() // Start unit test with your extension loaded + .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)); + + @Test + public void test() { + // Write your tests here - see the testing extension guide https://quarkus.io/guides/writing-extensions#testing-extensions for more information + Assertions.fail("Add some assertions to " + getClass().getName()); + } + +}