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 d46c0875c9339..e832a1339b1cb 100644 --- a/devtools/maven/src/main/java/io/quarkus/maven/CreateExtensionMojo.java +++ b/devtools/maven/src/main/java/io/quarkus/maven/CreateExtensionMojo.java @@ -368,6 +368,18 @@ public class CreateExtensionMojo extends AbstractMojo { @Parameter(property = "quarkus.itestParentPath") Path itestParentPath; + /** + * Indicates whether to generate a unit test class for the extension + */ + @Parameter(property = "quarkus.generateUnitTest", defaultValue = "true") + boolean generateUnitTest; + + /** + * Indicates whether to generate a dev mode unit test class for the extension + */ + @Parameter(property = "quarkus.generateDevModeTest", defaultValue = "true") + boolean generateDevModeTest; + @Parameter(defaultValue = "${project}", readonly = true) MavenProject project; @@ -498,6 +510,14 @@ void addModules(Path basePomXml, Model basePom, Charset charset) + "/deployment/" + model.artifactIdBaseCamelCase + "Processor.java"); evalTemplate(cfg, "Processor.java", processorPath, charset, model); + if (generateUnitTest) { + generateUnitTestClass(charset, cfg, model); + } + + if (generateDevModeTest) { + generateDevModeTestClass(charset, cfg, model); + } + if (!basePom.getModules().contains(model.artifactIdBase)) { getLog().info(String.format("Adding module [%s] to [%s]", model.artifactIdBase, basePomXml)); new PomTransformer(basePomXml, charset).transform(Transformation.addModule(model.artifactIdBase)); @@ -521,46 +541,67 @@ void addModules(Path basePomXml, Model basePom, Charset charset) .transform(Transformation.addManagedDependency(model.groupId, aId, model.bomEntryVersion)); } if (itestParentPath != null) { - generateItest(cfg, charset, model); + generateIntegrationTest(cfg, charset, model); } } - void generateItest(Configuration cfg, Charset charset, TemplateParams model) + private void generateUnitTestClass(Charset charset, Configuration cfg, TemplateParams model) + throws IOException, TemplateException { + final Path unitTest = basedir + .resolve(model.artifactIdBase + "/deployment/src/test/java/" + model.javaPackageBase.replace('.', '/') + + "/test/" + model.artifactIdBaseCamelCase + "UnitTest.java"); + + evalTemplate(cfg, "UnitTest.java", unitTest, charset, model); + } + + private void generateDevModeTestClass(Charset charset, Configuration cfg, TemplateParams model) + throws IOException, TemplateException { + + final Path devModeTest = basedir + .resolve(model.artifactIdBase + "/deployment/src/test/java/" + model.javaPackageBase.replace('.', '/') + + "/test/" + model.artifactIdBaseCamelCase + "DevModeTest.java"); + + evalTemplate(cfg, "DevModeTest.java", devModeTest, charset, model); + + } + + void generateIntegrationTest(Configuration cfg, Charset charset, TemplateParams model) throws MojoFailureException, MojoExecutionException, TemplateException { - final Path itestParentAbsPath = basedir.resolve(itestParentPath).toAbsolutePath(); - try (Reader r = Files.newBufferedReader(itestParentAbsPath, charset)) { - final Model itestParent = new MavenXpp3Reader().read(r); - if (!"pom".equals(itestParent.getPackaging())) { + final Path integrationTestsParentAbsPath = basedir.resolve(itestParentPath).toAbsolutePath(); + try (Reader r = Files.newBufferedReader(integrationTestsParentAbsPath, charset)) { + final Model integrationTestParent = new MavenXpp3Reader().read(r); + if (!"pom".equals(integrationTestParent.getPackaging())) { throw new MojoFailureException( - "Can add an extension integration test only under a project with packagin 'pom'; found: " - + itestParent.getPackaging() + " in " + itestParentAbsPath); + "Can add an extension integration test only under a project with packaging 'pom'; found: " + + integrationTestParent.getPackaging() + " in " + integrationTestsParentAbsPath); } - model.itestParentGroupId = getGroupId(itestParent); - model.itestParentArtifactId = itestParent.getArtifactId(); - model.itestParentVersion = getVersion(itestParent); + model.itestParentGroupId = getGroupId(integrationTestParent); + model.itestParentArtifactId = integrationTestParent.getArtifactId(); + model.itestParentVersion = getVersion(integrationTestParent); model.itestParentRelativePath = "../pom.xml"; - final Path itestDir = itestParentAbsPath.getParent().resolve(model.artifactIdBase); - evalTemplate(cfg, "integration-test-pom.xml", itestDir.resolve("pom.xml"), charset, model); + final Path integrationTestDir = integrationTestsParentAbsPath.getParent().resolve(model.artifactIdBase); + evalTemplate(cfg, "integration-test-pom.xml", integrationTestDir.resolve("pom.xml"), charset, model); - final Path testResourcePath = itestDir.resolve("src/main/java/" + model.javaPackageBase.replace('.', '/') + final Path testResourcePath = integrationTestDir.resolve("src/main/java/" + model.javaPackageBase.replace('.', '/') + "/it/" + model.artifactIdBaseCamelCase + "Resource.java"); evalTemplate(cfg, "TestResource.java", testResourcePath, charset, model); - final Path testClassDir = itestDir + final Path testClassDir = integrationTestDir .resolve("src/test/java/" + model.javaPackageBase.replace('.', '/') + "/it"); evalTemplate(cfg, "Test.java", testClassDir.resolve(model.artifactIdBaseCamelCase + "Test.java"), charset, model); evalTemplate(cfg, "IT.java", testClassDir.resolve(model.artifactIdBaseCamelCase + "IT.java"), charset, model); - getLog().info(String.format("Adding module [%s] to [%s]", model.artifactIdBase, itestParentAbsPath)); - new PomTransformer(itestParentAbsPath, charset).transform(Transformation.addModule(model.artifactIdBase)); + getLog().info(String.format("Adding module [%s] to [%s]", model.artifactIdBase, integrationTestsParentAbsPath)); + new PomTransformer(integrationTestsParentAbsPath, charset) + .transform(Transformation.addModule(model.artifactIdBase)); } catch (IOException e) { - throw new MojoExecutionException(String.format("Could not read %s", itestParentAbsPath), e); + throw new MojoExecutionException(String.format("Could not read %s", integrationTestsParentAbsPath), e); } catch (XmlPullParserException e) { - throw new MojoExecutionException(String.format("Could not parse %s", itestParentAbsPath), e); + throw new MojoExecutionException(String.format("Could not parse %s", integrationTestsParentAbsPath), e); } } 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..28eb61e936c69 --- /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]UnitTest { + + @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 13933a831cd6b..07c65d7269fa2 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 @@ -27,6 +27,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 ced952f9e2ec4..3bcca66e41a6c 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 @@ -20,8 +20,8 @@ public class CreateExtensionMojoTest { - static CreateExtensionMojo createMojo(String testProjectName) throws IllegalArgumentException, - IllegalAccessException, IOException, NoSuchFieldException, SecurityException { + static CreateExtensionMojo createMojo(String testProjectName) + throws IllegalArgumentException, IOException, SecurityException { final Path srcDir = Paths.get("src/test/resources/projects/" + testProjectName); /* * We want to run on the same project multiple times with different args so let's create a copy with a random @@ -44,6 +44,8 @@ static CreateExtensionMojo createMojo(String testProjectName) throws IllegalArgu mojo.quarkusVersion = CreateExtensionMojo.DEFAULT_QUARKUS_VERSION; mojo.bomEntryVersion = CreateExtensionMojo.DEFAULT_BOM_ENTRY_VERSION; mojo.assumeManaged = true; + mojo.generateDevModeTest = true; + mojo.generateUnitTest = true; mojo.nameSegmentDelimiter = CreateExtensionMojo.DEFAULT_NAME_SEGMENT_DELIMITER; return mojo; } @@ -64,7 +66,7 @@ private static Path getCopyDir(String testProjectName) { @Test void createExtensionUnderExistingPomMinimal() throws MojoExecutionException, MojoFailureException, - IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException, IOException { + IllegalArgumentException, SecurityException, IOException { final CreateExtensionMojo mojo = createMojo("create-extension-pom"); mojo.artifactId = "my-project-(minimal-extension)"; mojo.assumeManaged = false; @@ -76,7 +78,7 @@ void createExtensionUnderExistingPomMinimal() throws MojoExecutionException, Moj @Test void createExtensionUnderExistingPomWithAdditionalRuntimeDependencies() throws MojoExecutionException, MojoFailureException, - IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException, IOException { + IllegalArgumentException, SecurityException, IOException { final CreateExtensionMojo mojo = createMojo("create-extension-pom"); mojo.artifactId = "my-project-(add-to-bom)"; mojo.assumeManaged = false; @@ -90,8 +92,8 @@ void createExtensionUnderExistingPomWithAdditionalRuntimeDependencies() throws M } @Test - void createExtensionUnderExistingPomWithItest() throws MojoExecutionException, MojoFailureException, - IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException, IOException { + void createExtensionUnderExistingPomWithIntegrationTest() throws MojoExecutionException, MojoFailureException, + IllegalArgumentException, SecurityException, IOException { final CreateExtensionMojo mojo = createMojo("create-extension-pom"); mojo.artifactId = "my-project-(itest)"; mojo.assumeManaged = false; @@ -104,7 +106,7 @@ void createExtensionUnderExistingPomWithItest() throws MojoExecutionException, M @Test void createExtensionUnderExistingPomCustomGrandParent() throws MojoExecutionException, MojoFailureException, - IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException, IOException { + IllegalArgumentException, SecurityException, IOException { final CreateExtensionMojo mojo = createMojo("create-extension-pom"); mojo.artifactId = "myproject-(with-grand-parent)"; mojo.grandParentArtifactId = "build-bom"; @@ -148,7 +150,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 @@ -156,8 +158,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 07b184bee7bf8..f6b99b9b7efbf 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 @@ -24,6 +24,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/AddToBomUnitTest.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/AddToBomUnitTest.java new file mode 100644 index 0000000000000..dc3e1c2f01736 --- /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/AddToBomUnitTest.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 AddToBomUnitTest { + + @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 5c24622b286e4..9dc597a699952 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 @@ -24,6 +24,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/ItestUnitTest.java b/integration-tests/maven/src/test/resources/expected/create-extension-pom-itest/itest/deployment/src/test/java/org/acme/my/project/itest/test/ItestUnitTest.java new file mode 100644 index 0000000000000..970e37afbf31a --- /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/ItestUnitTest.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 ItestUnitTest { + + @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 cccab7d27e622..afd21a380e959 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 @@ -24,6 +24,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/MinimalExtensionUnitTest.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/MinimalExtensionUnitTest.java new file mode 100644 index 0000000000000..13cc9e2826897 --- /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/MinimalExtensionUnitTest.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 MinimalExtensionUnitTest { + + @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 ce7a99fad7dbd..f77c46befb62c 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/WithGrandParentUnitTest.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/WithGrandParentUnitTest.java new file mode 100644 index 0000000000000..95ea6fbc590c7 --- /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/WithGrandParentUnitTest.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 WithGrandParentUnitTest { + + @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()); + } + +}