{"id":64355,"date":"2020-08-29T17:00:29","date_gmt":"2020-08-29T17:00:29","guid":{"rendered":"https:\/\/www.baeldung.com\/?p=86352"},"modified":"2020-08-29T17:00:29","modified_gmt":"2020-08-29T17:00:29","slug":"testing-quarkus-applications","status":"publish","type":"post","link":"https:\/\/itteacheritfreelance.hk\/wordpress\/index.php\/2020\/08\/29\/testing-quarkus-applications\/","title":{"rendered":"Testing Quarkus Applications"},"content":{"rendered":"<p class=\"syndicated-attribution\"><meta name= \\\"keywords \\\" content= \\\"\u96fb\u5b50\u8a08\u7b97\u6a5f, \u6559\u80b2, IT \u96fb\u8166\u73ed,\u96fb\u8166\u88dc\u7fd2\uff0c \u96fb\u8166\u73ed\uff0c \u5bb6\u6559\uff0c \u79c1\u4eba\u8001\u5e2b\uff0c \u8cc7\u8a0a\u6280\u8853\uff0c \u7a0b\u5e8f\u8a2d\u8a08\uff0c \u96fb\u5b50\u8a08\u7b97\u6a5f\uff0c \u904a\u6232\uff0c \u860b\u679c\uff0c \u96fb\u5f71\uff0c \u8a08\u7b97\u6a5f\uff0c\u7de8\u78bc\uff0c Java\uff0c C\/C++\uff0c JavaScript\uff0c PHP\uff0c HTML\uff0c CSS\uff0c MySQL\uff0c mobile\uff0c Android\uff0c \u52d5\u6f2b\uff0c Python\uff0c teacher\uff0c \u88dc\u7fd2\uff0c \u96fb\u8166\u88dc\u7fd2 \u8cc7\u8a0a, \u7535\u5b50\u8ba1\u7b97\u673a, IT ,Game, apple, movie, Computer,student,Java,\u6559\u80b2, ,\u5b66\u751f, \u5b66\u4e60, learn, \u6559\u5b66,  Android, apple,anime, animation, \u4fe1\u606f\u6280\u672f, \u7a0b\u5e8f\u8bbe\u8ba1, \u79fb\u52a8\u7535\u8bdd, \u8cc7\u8a0a\u79d1\u6280,Game, Jeu, Juego,Call Of Duty ,\u4f7f\u547d\u53ec\u559a , \u6e38\u620f, \u7535\u5b50\u6e38\u620f,, \u591a\u4eba\u7535\u5b50\u6e38\u620f, \u7f51\u7edc\u6e38\u620f\uff0conline\uff0conline game, \u624b\u673a\u6e38\u620f, mobile \\\"><\/p>\n<h2 data-id=\"overview-1\">1. Overview<\/h2>\n<div class=\"bd-anchor\" id=\"overview-1\"><\/div>\n<p>Quarkus makes it very easy these days to develop robust and clean applications. But how about testing?<\/p>\n<p>In this tutorial, <strong>we&#8217;ll take a close look at how a Quarkus application can be tested<\/strong>. We&#8217;ll explore the testing possibilities offered by Quarkus and <strong>present concepts like dependency management and injection, mocking, profile configuration, and more specific things like Quarkus annotations and testing a native executable<\/strong>.<\/p>\n<h2 data-id=\"setup\">2. Setup<\/h2>\n<div class=\"bd-anchor\" id=\"setup\"><\/div>\n<p>Let&#8217;s start from the basic Quarkus project configured in our previous <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/www.baeldung.com\/quarkus-io\">Guide to QuarkusIO<\/a>.<\/p>\n<p>First, we&#8217;ll add the <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/search.maven.org\/classic\/#search%7Cga%7C1%7Cg%3A%22io.quarkus%22%20a%3A%22quarkus-resteasy-jackson%22\">quarkus-reasteasy-jackson<\/a>, <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/search.maven.org\/classic\/#search%7Cga%7C1%7Cg%3A%22io.quarkus%22%20a%3A%22quarkus-hibernate-orm-panache%22\">quarkus-hibernate-orm-panache<\/a>, <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/search.maven.org\/classic\/#search%7Cga%7C1%7Cg%3A%22io.quarkus%22%20a%3A%22quarkus-jdbc-h2%22\">quarkus-jdbc-h2<\/a>, <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/search.maven.org\/classic\/#search%7Cga%7C1%7Cg%3A%22io.quarkus%22%20a%3A%22quarkus-junit5-mockito%22\">quarkus-junit5-mockito<\/a>, and <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/search.maven.org\/classic\/#search%7Cga%7C1%7Cg%3A%22io.quarkus%22%20a%3A%22quarkus-test-h2%22\">quarkus-test-h2<\/a> Maven dependencies:<\/p>\n<pre><code class=\"language-xml\">&lt;dependency&gt;\r\n    &lt;groupId&gt;io.quarkus&lt;\/groupId&gt;\r\n    &lt;artifactId&gt;quarkus-resteasy-jackson&lt;\/artifactId&gt;\r\n&lt;\/dependency&gt;\r\n&lt;dependency&gt;\r\n    &lt;groupId&gt;io.quarkus&lt;\/groupId&gt;\r\n    &lt;artifactId&gt;quarkus-hibernate-orm-panache&lt;\/artifactId&gt;\r\n&lt;\/dependency&gt;\r\n&lt;dependency&gt;\r\n    &lt;groupId&gt;io.quarkus&lt;\/groupId&gt;\r\n    &lt;artifactId&gt;quarkus-jdbc-h2&lt;\/artifactId&gt;\r\n&lt;\/dependency&gt;\r\n&lt;dependency&gt;\r\n    &lt;groupId&gt;io.quarkus&lt;\/groupId&gt;\r\n    &lt;artifactId&gt;quarkus-junit5-mockito&lt;\/artifactId&gt;\r\n&lt;\/dependency&gt;\r\n&lt;dependency&gt;\r\n    &lt;groupId&gt;io.quarkus&lt;\/groupId&gt;\r\n    &lt;artifactId&gt;quarkus-test-h2&lt;\/artifactId&gt;\r\n&lt;\/dependency&gt;<\/code><\/pre>\n<p>Next, let&#8217;s create our domain entity:<\/p>\n<pre><code class=\"language-java\">public class Book extends PanacheEntity {\r\n    private String title;\r\n    private String author;\r\n}<\/code><\/pre>\n<p>We continue by adding a simple Panache repository, with a method to search for books:<\/p>\n<pre><code class=\"language-java\">public class BookRepository implements PanacheRepository {\r\n    public Stream&lt;Book&gt; findBy(String query) {\r\n        return find(\"author like :query or title like :query\", with(\"query\", \"%\"+query+\"%\")).stream();\r\n    }\r\n}<\/code><\/pre>\n<p>Now, let&#8217;s write a <em>LibraryService <\/em>to hold any business logic:<\/p>\n<pre><code class=\"language-java\">public class LibraryService {\r\n    public Set&lt;Book&gt; find(String query) {\r\n        if (query == null) {\r\n            return bookRepository.findAll().stream().collect(toSet());\r\n        }\r\n        return bookRepository.findBy(query).collect(toSet());\r\n    }\r\n}<\/code><\/pre>\n<p>And finally, let&#8217;s expose our service functionality through HTTP by creating a <em>LibraryResource<\/em>:<\/p>\n<pre><code class=\"language-java\">@Path(\"\/library\")\r\npublic class LibraryResource {\r\n    @GET\r\n    @Path(\"\/book\")\r\n    public Set findBooks(@QueryParam(\"query\") String query) {\r\n        return libraryService.find(query);\r\n    }\r\n}<\/code><\/pre>\n<h2 data-id=\"alternative-implementations\">3. <em>@Alternative<\/em> Implementations<\/h2>\n<div class=\"bd-anchor\" id=\"alternative-implementations\"><\/div>\n<p>Before writing any tests, let&#8217;s make sure we have some books in our repository. With Quarkus, <strong>we can use the CDI <em>@Alternative<\/em> mechanism to provide a custom bean implementation for our tests<\/strong>. Let&#8217;s create a <em>TestBookRepository<\/em> that extends <em>BookRepository<\/em>:<\/p>\n<pre><code class=\"language-java\">@Priority(1)\r\n@Alternative\r\n@ApplicationScoped\r\npublic class TestBookRepository extends BookRepository {\r\n    @PostConstruct\r\n    public void init() {\r\n        persist(new Book(\"Dune\", \"Frank Herbert\"),\r\n          new Book(\"Foundation\", \"Isaac Asimov\"));\r\n    }\r\n}<\/code><\/pre>\n<p>We place this alternative bean in our <em>test<\/em> package, and because of the <em>@Priority(1)<\/em> and <em>@Alternative<\/em> annotations, we&#8217;re sure any test will pick it up over the actual <em>BookRepository<\/em> implementation. This <strong>is one way we can provide a global mock that all our Quarkus tests<\/strong> can use. We&#8217;ll explore more narrow-focused mocks shortly, but now, let&#8217;s move on to creating our first test.<\/p>\n<h2 data-id=\"http-integration-test\">4. HTTP Integration Test<\/h2>\n<div class=\"bd-anchor\" id=\"http-integration-test\"><\/div>\n<p>Let&#8217;s begin by creating a simple REST-assured integration test:<\/p>\n<pre><code class=\"language-java\">@QuarkusTest\r\nclass LibraryResourceIntegrationTest {\r\n    @Test\r\n    void whenGetBooksByTitle_thenBookShouldBeFound() {\r\n        given().contentType(ContentType.JSON).param(\"query\", \"Dune\")\r\n          .when().get(\"\/library\/book\")\r\n          .then().statusCode(200)\r\n          .body(\"size()\", is(1))\r\n          .body(\"title\", hasItem(\"Dune\"))\r\n          .body(\"author\", hasItem(\"Frank Herbert\"));\r\n    }\r\n}<\/code><\/pre>\n<p>This <strong>test, annotated with <em>@QuarkusTest,<\/em> first starts the Quarkus application<\/strong> and then performs a series of HTTP requests against our resource&#8217;s endpoint.<\/p>\n<p>Now, let&#8217;s make use of some Quarkus mechanisms to try and further improve our test.<\/p>\n<h3 data-id=\"1-url-injection-with-testhttpresource\">4.1. URL Injection With <em>@TestHTTPResource<\/em><\/h3>\n<div class=\"bd-anchor\" id=\"1-url-injection-with-testhttpresource\"><\/div>\n<p>Instead of hard-coding the path of our HTTP endpoint, let&#8217;s inject the resource URL:<\/p>\n<pre><code class=\"language-java\">@TestHTTPResource(\"\/library\/book\")\r\nURL libraryEndpoint;<\/code><\/pre>\n<p>And then, let&#8217;s use it in our requests:<\/p>\n<pre><code class=\"language-java\">given().param(\"query\", \"Dune\")\r\n  .when().get(libraryEndpoint)\r\n  .then().statusCode(200);<\/code><\/pre>\n<p>Or, without using Rest-assured, let&#8217;s simply open a connection to the injected URL and test the response:<\/p>\n<pre><code class=\"language-java\">@Test\r\nvoid whenGetBooks_thenBooksShouldBeFound() throws IOException {\r\n    assertTrue(IOUtils.toString(libraryEndpoint.openStream(), defaultCharset()).contains(\"Asimov\"));\r\n}<\/code><\/pre>\n<p>As we can see, <em>@TestHTTPResource <\/em>URL injection gives us an easy and flexible way of accessing our endpoint.<\/p>\n<h3 data-id=\"2-testhttpendpoint\">4.2. <em>@TestHTTPEndpoint<\/em><\/h3>\n<div class=\"bd-anchor\" id=\"2-testhttpendpoint\"><\/div>\n<p>Let&#8217;s take this further and configure our endpoint using the Quarkus provided <em>@TestHTTPEndpoint<\/em> annotation:<\/p>\n<pre><code class=\"language-java\">@TestHTTPEndpoint(LibraryResource.class)\r\n@TestHTTPResource(\"book\")\r\nURL libraryEndpoint;<\/code><\/pre>\n<p>This way, if we ever decide to change the path of the <em>LibraryResource<\/em>, the test will pick up the correct path without us having to touch it.<\/p>\n<p><strong><em>@TestHTTPEndpoint <\/em>can also be applied at the class level, in which case REST-assured will automatically prefix all requests with the <em>Path<\/em><\/strong> of the <em>LibraryResource<\/em>:<\/p>\n<pre><code class=\"language-java\">@QuarkusTest\r\n@TestHTTPEndpoint(LibraryResource.class)\r\nclass LibraryHttpEndpointIntegrationTest {\r\n    @Test\r\n    void whenGetBooks_thenShouldReturnSuccessfully() {\r\n        given().contentType(ContentType.JSON)\r\n          .when().get(\"book\")\r\n          .then().statusCode(200);\r\n    }\r\n}<\/code><\/pre>\n<h2 data-id=\"context-and-dependency-injection\">5. Context and Dependency Injection<\/h2>\n<div class=\"bd-anchor\" id=\"context-and-dependency-injection\"><\/div>\n<p>When it comes to dependency injection, <strong>in Quarkus tests, we can use <em>@Inject<\/em> for any required dependency<\/strong>. Let&#8217;s see this in action by creating a test for our <em>LibraryService<\/em>:<\/p>\n<pre><code class=\"language-java\">@QuarkusTest\r\nclass LibraryServiceIntegrationTest {\r\n    @Inject\r\n    LibraryService libraryService;\r\n    @Test\r\n    void whenFindByAuthor_thenBookShouldBeFound() {\r\n        assertFalse(libraryService.find(\"Frank Herbert\").isEmpty());\r\n    }\r\n}<\/code><\/pre>\n<p>Now, let&#8217;s try to test our Panache <em>BookRepository<\/em>:<\/p>\n<pre><code class=\"language-java\">class BookRepositoryIntegrationTest {\r\n    @Inject\r\n    BookRepository bookRepository;\r\n    @Test\r\n    void givenBookInRepository_whenFindByAuthor_thenShouldReturnBookFromRepository() {\r\n        assertTrue(bookRepository.findBy(\"Herbert\").findAny().isPresent());\r\n    }\r\n}<\/code><\/pre>\n<p>But when we run our test, it fails. That&#8217;s because it <strong>requires running within the context of a transaction<\/strong> and there is none active. This can be fixed simply by adding <em>@Transactional<\/em> to the test class. Or, if we prefer, we can define our own stereotype to bundle both <em>@QuarkusTest<\/em> and <em>@Transactional. <\/em>Let&#8217;s do this by creating the <em>@QuarkusTransactionalTest<\/em> annotation:<\/p>\n<pre><code class=\"language-java\">@QuarkusTest\r\n@Stereotype\r\n@Transactional\r\n@Target(ElementType.TYPE)\r\n@Retention(RetentionPolicy.RUNTIME)\r\npublic @interface QuarkusTransactionalTest {\r\n}<\/code><\/pre>\n<p>Now, let&#8217;s apply it to our test:<\/p>\n<pre><code class=\"language-java\">@QuarkusTransactionalTest\r\nclass BookRepositoryIntegrationTest<\/code><\/pre>\n<p>As we can see, because <strong>Quarkus tests are full CDI beans<\/strong>, we can take advantage of all the CDI benefits like dependency injection, transactional contexts, and CDI interceptors.<\/p>\n<h2 data-id=\"mocking\">6. Mocking<\/h2>\n<div class=\"bd-anchor\" id=\"mocking\"><\/div>\n<p>Mocking is a critical aspect of any testing effort. As we&#8217;ve already seen above, Quarkus tests can make use of the CDI <em>@Alternative<\/em> mechanism. Let&#8217;s now dive deeper into the mocking capabilities Quarkus has to offer.<\/p>\n<h3 data-id=\"1-mock\">6.1. <em>@Mock<\/em><\/h3>\n<div class=\"bd-anchor\" id=\"1-mock\"><\/div>\n<p>As <strong>a slight simplification of the <em>@Alternative<\/em> approach<\/strong>, we can use the <em>@Mock<\/em> stereotype annotation. This bundles together the <em>@Alternative<\/em> and <em>@Primary(1)<\/em> annotations.<\/p>\n<h3 data-id=\"2-quarkusmock\">6.2. <em>@QuarkusMock<\/em><\/h3>\n<div class=\"bd-anchor\" id=\"2-quarkusmock\"><\/div>\n<p>If we don&#8217;t want to have a globally defined mock, but would rather <strong>have our mock only within the scope of one test<\/strong>, we can use <em>@QuarkusMock<\/em>:<\/p>\n<pre><code class=\"language-java\">@QuarkusTest\r\nclass LibraryServiceQuarkusMockUnitTest {\r\n    @Inject\r\n    LibraryService libraryService;\r\n    @BeforeEach\r\n    void setUp() {\r\n        BookRepository mock = Mockito.mock(TestBookRepository.class);\r\n        Mockito.when(mock.findBy(\"Asimov\"))\r\n          .thenReturn(Arrays.stream(new Book[] {\r\n            new Book(\"Foundation\", \"Isaac Asimov\"),\r\n            new Book(\"I Robot\", \"Isaac Asimov\")}));\r\n        QuarkusMock.installMockForType(mock, BookRepository.class);\r\n    }\r\n    @Test\r\n    void whenFindByAuthor_thenBooksShouldBeFound() {\r\n        assertEquals(2, libraryService.find(\"Asimov\").size());\r\n    }\r\n}<\/code><\/pre>\n<h3 data-id=\"3-injectmock\">6.3. <em>@InjectMock<\/em><\/h3>\n<div class=\"bd-anchor\" id=\"3-injectmock\"><\/div>\n<p>Let&#8217;s simplify things a bit and <strong>use the Quarkus<em> @InjectMock <\/em>annotation instead of <em>@QuarkusMock<\/em><\/strong>:<\/p>\n<pre><code class=\"language-java\">@QuarkusTest\r\nclass LibraryServiceInjectMockUnitTest {\r\n    @Inject\r\n    LibraryService libraryService;\r\n    @InjectMock\r\n    BookRepository bookRepository;\r\n    @BeforeEach\r\n    void setUp() {\r\n        when(bookRepository.findBy(\"Frank Herbert\"))\r\n          .thenReturn(Arrays.stream(new Book[] {\r\n            new Book(\"Dune\", \"Frank Herbert\"),\r\n            new Book(\"Children of Dune\", \"Frank Herbert\")}));\r\n    }\r\n    @Test\r\n    void whenFindByAuthor_thenBooksShouldBeFound() {\r\n        assertEquals(2, libraryService.find(\"Frank Herbert\").size());\r\n    }\r\n}<\/code><\/pre>\n<h3 data-id=\"4-injectspy\">6.4. <em>@InjectSpy<\/em><\/h3>\n<div class=\"bd-anchor\" id=\"4-injectspy\"><\/div>\n<p>If we&#8217;re only interested in spying and not replacing bean behavior, we can use the provided <em>@InjectSpy<\/em> annotation:<\/p>\n<pre><code class=\"language-java\">@QuarkusTest\r\nclass LibraryResourceInjectSpyIntegrationTest {\r\n    @InjectSpy\r\n    LibraryService libraryService;\r\n    @Test\r\n    void whenGetBooksByAuthor_thenBookShouldBeFound() {\r\n        given().contentType(ContentType.JSON).param(\"query\", \"Asimov\")\r\n          .when().get(\"\/library\/book\")\r\n          .then().statusCode(200);\r\n        verify(libraryService).find(\"Asimov\");\r\n    }\r\n}<\/code><\/pre>\n<h2 data-id=\"test-profiles\">7. Test Profiles<\/h2>\n<div class=\"bd-anchor\" id=\"test-profiles\"><\/div>\n<p>We might want <strong>to run our tests in different configurations<\/strong>. For this, <strong>Quarkus offers the concept of a test profile<\/strong>. Let&#8217;s create a test that runs against a different database engine using a customized version of our <em>BookRepository<\/em>, and that will also expose our HTTP resources at a different path from the one already configured.<\/p>\n<p>For this, we start by implementing a <em>QuarkusTestProfile<\/em>:<\/p>\n<pre><code class=\"language-java\">public class CustomTestProfile implements QuarkusTestProfile {\r\n    @Override\r\n    public Map&lt;String, String&gt; getConfigOverrides() {\r\n        return Collections.singletonMap(\"quarkus.resteasy.path\", \"\/custom\");\r\n    }\r\n    @Override\r\n    public Set&lt;Class&lt;?&gt;&gt; getEnabledAlternatives() {\r\n        return Collections.singleton(TestBookRepository.class);\r\n    }\r\n    @Override\r\n    public String getConfigProfile() {\r\n        return \"custom-profile\";\r\n    }\r\n}<\/code><\/pre>\n<p>Let&#8217;s now configure our <em>application.properties<\/em> by adding a <em>custom-profile<\/em> config property that will change our H2 storage from memory to file:<\/p>\n<pre><code class=\"language-bash\">%custom-profile.quarkus.datasource.jdbc.url = jdbc:h2:file:.\/testdb<\/code><code class=\"language-java\"><\/code><\/pre>\n<p>Finally, with all the resources and configuration in place, let&#8217;s write our test:<\/p>\n<pre><code class=\"language-java\">@QuarkusTest\r\n@TestProfile(CustomBookRepositoryProfile.class)\r\nclass CustomLibraryResourceManualTest {\r\n    public static final String BOOKSTORE_ENDPOINT = \"\/custom\/library\/book\";\r\n    @Test\r\n    void whenGetBooksGivenNoQuery_thenAllBooksShouldBeReturned() {\r\n        given().contentType(ContentType.JSON)\r\n          .when().get(BOOKSTORE_ENDPOINT)\r\n          .then().statusCode(200)\r\n          .body(\"size()\", is(2))\r\n          .body(\"title\", hasItems(\"Foundation\", \"Dune\"));\r\n    }\r\n}<\/code><\/pre>\n<p>As we can see from the <em>@TestProfile<\/em> annotation, this test will use the <em>CustomTestProfile<\/em><em>. <\/em>It will make HTTP requests to the custom endpoint overridden in the profile&#8217;s <em>getConfigOverrides<\/em> method. Moreover, it will use the alternative book repository implementation configured in the <em>getEnabledAlternatives<\/em> method. And finally, by using the <em>custom-profile <\/em>defined in <em>getConfigProfile<\/em>, it will persist data in a file rather than memory.<\/p>\n<p>One thing to note is that <strong>Quarkus will shut down and then restart with the new profile before this test is executed<\/strong>. This adds some time as the shutdown\/restart happens, but it&#8217;s the price to be paid for the extra flexibility.<\/p>\n<h2 data-id=\"testing-native-executables\">8. Testing Native Executables<\/h2>\n<div class=\"bd-anchor\" id=\"testing-native-executables\"><\/div>\n<p>Quarkus offers the possibility to test native executables. Let&#8217;s create a native image test:<\/p>\n<pre><code class=\"language-java\">@NativeImageTest\r\n@QuarkusTestResource(H2DatabaseTestResource.class)\r\nclass NativeLibraryResourceIT extends LibraryHttpEndpointIntegrationTest {\r\n}<\/code><\/pre>\n<p>And now, by running:<\/p>\n<pre><code class=\"language-bash\">mvn verify -Pnative<\/code><\/pre>\n<p>We&#8217;ll see the native image being built and the tests running against it.<\/p>\n<p>The <em>@NativeImageTest <\/em>annotation instructs Quarkus to run this test against the native image, while the <em>@QuarkusTestResource <\/em>will start an H2 instance into a separate process before the test begins. The latter is needed for running tests against native executables as the database engine is not embedded into the native image.<\/p>\n<p>The @<em>QuarkusTestResource<\/em> annotation can also be used to start custom services, like Testcontainers, for example. All we need to do is implement the <em>QuarkusTestResourceLifecycleManager<\/em> interface and annotate our test with:<\/p>\n<pre><code class=\"language-java\">@QuarkusTestResource(OurCustomResourceImpl.class)<\/code><\/pre>\n<p>You will need a <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/quarkus.io\/guides\/building-native-image#configuring-graalvm\">GraalVM for building the native image<\/a>.<\/p>\n<p>Also, take notice that, at the moment, injection does not work with native image testing. <strong>The only thing that runs natively is the Quarkus application, not the test itself<\/strong>.<\/p>\n<h2 data-id=\"conclusion-1\">9. Conclusion<\/h2>\n<div class=\"bd-anchor\" id=\"conclusion-1\"><\/div>\n<p>In this article, we saw how <strong>Quarkus offers excellent support for testing<\/strong> our application. From simple things like dependency management, injection, and mocking, to more complex aspects like configuration profiles and native images, Quarkus provides us with many tools to create powerful and clean tests.<\/p>\n<p>As always, the complete code is available <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/github.com\/eugenp\/tutorials\/tree\/master\/quarkus\">over on GitHub<\/a>.<\/p>\n<p>The post <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/www.baeldung.com\/java-quarkus-testing\/\" >Testing Quarkus Applications<\/a> first appeared on <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/www.baeldung.com\/\" >Baeldung<\/a>.<\/p>\n<p><Img align=\"left\" border=\"0\" height=\"1\" width=\"1\" alt=\"\" style=\"border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;\" hspace=\"0\" src=\"https:\/\/feeds.feedblitz.com\/~\/i\/634758578\/0\/baeldung\"><\/p>\n<div style=\"clear:both;padding-top:0.2em;\"><a title=\"Like on Facebook\" href=\"https:\/\/feeds.feedblitz.com\/_\/28\/634758578\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/fblike20.png\" style=\"border:0;margin:0;padding:0;\"><\/a>&#160;<a title=\"Share on Google+\" href=\"https:\/\/feeds.feedblitz.com\/_\/30\/634758578\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/googleplus20.png\" style=\"border:0;margin:0;padding:0;\"><\/a>&#160;<a title=\"Pin it!\" href=\"https:\/\/feeds.feedblitz.com\/_\/29\/634758578\/baeldung,\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/pinterest20.png\" style=\"border:0;margin:0;padding:0;\"><\/a>&#160;<a title=\"Tweet This\" href=\"https:\/\/feeds.feedblitz.com\/_\/24\/634758578\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/twitter20.png\" style=\"border:0;margin:0;padding:0;\"><\/a>&#160;<a title=\"Subscribe by email\" href=\"https:\/\/feeds.feedblitz.com\/_\/19\/634758578\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/email20.png\" style=\"border:0;margin:0;padding:0;\"><\/a>&#160;<a title=\"Subscribe by RSS\" href=\"https:\/\/feeds.feedblitz.com\/_\/20\/634758578\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/rss20.png\" style=\"border:0;margin:0;padding:0;\"><\/a>&#160;<a rel=\"NOFOLLOW\" title=\"View Comments\" href=\"https:\/\/www.baeldung.com\/java-quarkus-testing#respond\"><img decoding=\"async\" height=\"20\" style=\"border:0;margin:0;padding:0;\" src=\"https:\/\/assets.feedblitz.com\/i\/comments20.png\"><\/a>&#160;<a title=\"Follow Comments via RSS\" href=\"https:\/\/www.baeldung.com\/java-quarkus-testing\/feed\/\"><img decoding=\"async\" height=\"20\" style=\"border:0;margin:0;padding:0;\" src=\"https:\/\/assets.feedblitz.com\/i\/commentsrss20.png\"><\/a>&#160;<\/div>\n\n<p class=\"syndicated-attribution\"><figure class= \\\"wp-block-image alignnone \\\"><img src= \\\"http:\/\/itteacheritfreelance.hk\/test\/wordpress\/wp-content\/uploads\/2016\/05\/logo2-2.png\\\" alt=\\\"IT\u96fb\u8166\u88dc\u7fd2 java\u88dc\u7fd2 \u70ba\u5927\u5bb6\u914d\u5c0d\u96fb\u8166\u88dc\u7fd2,IT freelance, \u79c1\u4eba\u8001\u5e2b, PHP\u88dc\u7fd2,CSS\u88dc\u7fd2,XML,Java\u88dc\u7fd2,MySQL\u88dc\u7fd2,graphic design\u88dc\u7fd2,\u4e2d\u5c0f\u5b78ICT\u88dc\u7fd2,\u4e00\u5c0d\u4e00\u79c1\u4eba\u88dc\u7fd2\u548cFreelance\u81ea\u7531\u5de5\u4f5c\u914d\u5c0d\u3002\\\"\/><figcaption>\u7acb\u523b\u8a3b\u518a\u53ca\u5831\u540d\u96fb\u8166\u88dc\u7fd2\u8ab2\u7a0b\u5427!<\/figcaption><\/figure>\r\n<\/br>Find A Teacher Form:\r\n<\/br>https:\/\/docs.google.com\/forms\/d\/1vREBnX5n262umf4wU5U2pyTwvk9O-JrAgblA-wH9GFQ\/viewform?edit_requested=true#responses\r\n<\/br><\/br>Email:\r\n<\/br>public1989two@gmail.com<br><br><br><br><br><br><br>\r\n<a href=www.itsec.hk style=color:#FFFFFF;>www.itsec.hk<\/a><br>\r\n<a href=\\\"www.itsec.vip\\\" style=color:#FFFFFF;>www.itsec.vip<\/a><br>\r\n<a href=\\\"www.itseceu.uk\\\" style=color:#FFFFFF;>www.itseceu.uk<\/a><br><\/p>","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>Learn how to write clean and powerful unit and integration tests for Quarkus applications.<\/p>\n<p>The post <a rel=\"NOFOLLOW noopener noreferrer\" href=\"https:\/\/feeds.feedblitz.com\/~\/634758578\/0\/baeldung~Testing-Quarkus-Applications\/\" target=\"_blank\">Testing Quarkus Applications<\/a> first appeared on <a rel=\"NOFOLLOW noopener noreferrer\" href=\"https:\/\/www.baeldung.com\/\" target=\"_blank\">Baeldung<\/a>.<\/p>\n<div><a title=\"Like on Facebook\" href=\"https:\/\/feeds.feedblitz.com\/_\/28\/634758578\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/fblike20.png\"><\/a>&nbsp;<a title=\"Share on Google+\" href=\"https:\/\/feeds.feedblitz.com\/_\/30\/634758578\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/googleplus20.png\"><\/a>&nbsp;<a title=\"Pin it!\" href=\"https:\/\/feeds.feedblitz.com\/_\/29\/634758578\/baeldung,\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/pinterest20.png\"><\/a>&nbsp;<a title=\"Tweet This\" href=\"https:\/\/feeds.feedblitz.com\/_\/24\/634758578\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/twitter20.png\"><\/a>&nbsp;<a title=\"Subscribe by email\" href=\"https:\/\/feeds.feedblitz.com\/_\/19\/634758578\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/email20.png\"><\/a>&nbsp;<a title=\"Subscribe by RSS\" href=\"https:\/\/feeds.feedblitz.com\/_\/20\/634758578\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/rss20.png\"><\/a>&nbsp;<a rel=\"NOFOLLOW\" title=\"View Comments\" href=\"https:\/\/www.baeldung.com\/java-quarkus-testing#respond\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/comments20.png\"><\/a>&nbsp;<a title=\"Follow Comments via RSS\" href=\"https:\/\/www.baeldung.com\/java-quarkus-testing\/feed\/\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/commentsrss20.png\"><\/a>&nbsp;<\/div>\n<\/div>","protected":false},"author":214,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"slim_seo":{"title":"Testing Quarkus Applications - ITTeacherITFreelance.hk","description":"Learn how to write clean and powerful unit and integration tests for Quarkus applications. The post Testing Quarkus Applications first appeared on Baeldung . &n"},"footnotes":""},"categories":[6],"tags":[],"_links":{"self":[{"href":"https:\/\/itteacheritfreelance.hk\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/64355"}],"collection":[{"href":"https:\/\/itteacheritfreelance.hk\/wordpress\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itteacheritfreelance.hk\/wordpress\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itteacheritfreelance.hk\/wordpress\/index.php\/wp-json\/wp\/v2\/users\/214"}],"replies":[{"embeddable":true,"href":"https:\/\/itteacheritfreelance.hk\/wordpress\/index.php\/wp-json\/wp\/v2\/comments?post=64355"}],"version-history":[{"count":8,"href":"https:\/\/itteacheritfreelance.hk\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/64355\/revisions"}],"predecessor-version":[{"id":68254,"href":"https:\/\/itteacheritfreelance.hk\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/64355\/revisions\/68254"}],"wp:attachment":[{"href":"https:\/\/itteacheritfreelance.hk\/wordpress\/index.php\/wp-json\/wp\/v2\/media?parent=64355"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itteacheritfreelance.hk\/wordpress\/index.php\/wp-json\/wp\/v2\/categories?post=64355"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itteacheritfreelance.hk\/wordpress\/index.php\/wp-json\/wp\/v2\/tags?post=64355"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}