{"id":108081,"date":"2020-12-23T07:00:00","date_gmt":"2020-12-23T05:00:00","guid":{"rendered":"https:\/\/www.javacodegeeks.com\/?p=108081"},"modified":"2020-12-17T17:10:29","modified_gmt":"2020-12-17T15:10:29","slug":"testing-using-testcontainers","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2020\/12\/testing-using-testcontainers.html","title":{"rendered":"Testing using TestContainers"},"content":{"rendered":"<p>Part of our everyday ci\/cd tasks involve using containers in order for the tests to take effect.<br \/>So what if you could control the containers you use through your tests and serve your scenarios better.<br \/>Also what if you could do this in a more managed way?<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><a href=\"https:\/\/egkatzioura.files.wordpress.com\/2020\/11\/test-containers.png\"><img decoding=\"async\" src=\"https:\/\/egkatzioura.files.wordpress.com\/2020\/11\/test-containers.png?w=470&amp;h=235\" alt=\"\"\/><\/a><\/figure>\n<\/div>\n<p><a href=\"https:\/\/www.testcontainers.org\/\">Testcontainers<\/a> is a Java library that supports JUnit tests, providing lightweight, throwaway instances of common databases, Selenium web browsers, or anything else that can run in a Docker container.<\/p>\n<p>You pretty much can guess what is all about. Our tests can spin up the containers with the parameters needed. We will get started by using it in our tests with Junit.<\/p>\n<p>It all starts with the right dependencies. Supposing we use maven for this tutorial.<\/p>\n<pre class=\"wp-block-preformatted brush:java\">&lt;properties&gt;\n\t\t&lt;junit-jupiter.version&gt;5.4.2&lt;\/junit-jupiter.version&gt;\n\t\t&lt;testcontainers.version&gt;1.15.0&lt;\/testcontainers.version&gt;\n\t&lt;\/properties&gt;\n\n\t&lt;dependencies&gt;\n\t\t&lt;dependency&gt;\n\t\t\t&lt;groupId&gt;org.testcontainers&lt;\/groupId&gt;\n\t\t\t&lt;artifactId&gt;testcontainers&lt;\/artifactId&gt;\n\t\t\t&lt;version&gt;${testcontainers.version}&lt;\/version&gt;\n\t\t\t&lt;scope&gt;test&lt;\/scope&gt;\n\t\t&lt;\/dependency&gt;\n\n\t\t&lt;dependency&gt;\n\t\t\t&lt;groupId&gt;org.testcontainers&lt;\/groupId&gt;\n\t\t\t&lt;artifactId&gt;junit-jupiter&lt;\/artifactId&gt;\n\t\t\t&lt;version&gt;${testcontainers.version}&lt;\/version&gt;\n\t\t\t&lt;scope&gt;test&lt;\/scope&gt;\n\t\t&lt;\/dependency&gt;\n\t&lt;\/dependencies&gt;<\/pre>\n<p>I shall use an example we already have with <a href=\"https:\/\/egkatzioura.com\/2020\/08\/09\/testing-with-hoverfly-and-java-part-1-get-started-with-simulation-mode\/\">Hoverfly<\/a>.<br \/>We can use Hoverfly on our tests either by running it using Java or having a Hoverfly container with the test cases preloaded.<br \/>On the previous blog Hoverfly was integrated in our tests through the Java binary.<br \/>For this blog we shall use the Hoverfly <a href=\"https:\/\/hub.docker.com\/r\/spectolabs\/hoverfly\/\">container<\/a>.<\/p>\n<p>Our end result will look like this.<\/p>\n<pre class=\"wp-block-preformatted brush:java\">package com.gkatzioura.hoverfly.docker;\n\nimport java.net.URI;\nimport java.net.http.HttpClient;\nimport java.net.http.HttpRequest;\nimport java.net.http.HttpResponse;\n\nimport org.junit.jupiter.api.Assertions;\nimport org.junit.jupiter.api.Test;\nimport org.testcontainers.containers.BindMode;\nimport org.testcontainers.containers.GenericContainer;\nimport org.testcontainers.junit.jupiter.Container;\nimport org.testcontainers.junit.jupiter.Testcontainers;\n\n@Testcontainers\npublic class ContainerBasedSimulation {\n\n\tprivate static final String SIMULATION_HOST_PATH = ContainerBasedSimulation.class.getClassLoader().getResource(\"simulation.json\").getPath();\n\n\t@Container\n\tpublic static GenericContainer gcs = new GenericContainer(\"spectolabs\/hoverfly\")\n\t\t\t.withExposedPorts(8888)\n\t\t\t.withExposedPorts(8500)\n\t\t\t.withCommand(\"-webserver\",\"-import\",\"\/var\/hoverfly\/simulation.json\")\n\t\t\t.withClasspathResourceMapping(\"simulation.json\",\"\/var\/hoverfly\/simulation.json\" ,BindMode.READ_ONLY);\n\n\n\t@Test\n\tvoid testHttpGet() {\n\t\tvar hoverFlyHost = gcs.getHost();\n\t\tvar hoverFlyPort = gcs.getMappedPort(8500);\n\t\tvar client = HttpClient.newHttpClient();\n\t\tvar request = HttpRequest.newBuilder()\n\t\t\t\t.uri(URI.create(\"http:\/\/\"+hoverFlyHost+\":\"+ hoverFlyPort +\"\/user\"))\n\t\t\t\t.build();\n\t\tvar res = client.sendAsync(request, HttpResponse.BodyHandlers.ofString())\n\t\t\t\t.thenApply(HttpResponse::body)\n\t\t\t\t.join();\n\t\tAssertions.assertEquals(\"{\\\"username\\\":\\\"test-user\\\"}\",res);\n\t}\n\n}<\/pre>\n<p>Let\u2019s break it down.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p>The @Testcontainers annotation is needed for the Jupiter integration.<\/p>\n<pre class=\"wp-block-preformatted brush:java\">@Testcontainers\npublic class ContainerBasedSimulation {\n}<\/pre>\n<p>We shall use a container image that is not preloaded among the test containers available (for example <a href=\"https:\/\/www.testcontainers.org\/modules\/elasticsearch\/\">Elastic Search<\/a>), thus we shall use the GenericContainer class.<\/p>\n<pre class=\"wp-block-preformatted brush:java\">@Container\npublic static GenericContainer gcs = new GenericContainer(\"spectolabs\/hoverfly\")<\/pre>\n<p>Since we want to load to the container a simulation, we need to set the path to our simulation from our host machine. By using withClasspathResourceMapping we directly specify files in our classpath, for example the test resources.<\/p>\n<pre class=\"wp-block-preformatted brush:java\">.withClasspathResourceMapping(\"simulation.json\",\"\/var\/hoverfly\/simulation.json\",BindMode.READ_ONLY);<\/pre>\n<p>Hoverfly needs the simulation and the admin port to be exposed so we shall instruct Testcontainers to expose those ports and map them to host.<\/p>\n<pre class=\"wp-block-preformatted brush:java\">new GenericContainer(\"spectolabs\/hoverfly\")\n\t\t\t.withExposedPorts(8888)\n\t\t\t.withExposedPorts(8500)<\/pre>\n<p>We need to have a simulation placed on the container. By using withFileSystemBind we specify the local path and the path on the container.<\/p>\n<pre class=\"wp-block-preformatted brush:java\">...\n.withFileSystemBind(SIMULATION_HOST_PATH,\"\/var\/hoverfly\/simulation.json\" ,BindMode.READ_ONLY)\n...<\/pre>\n<p>Also docker images might need to have some extra commands, therefore we shall use .withCommand, to pass the commands needed.<\/p>\n<pre class=\"wp-block-preformatted brush:java\">...\n.withCommand(\"-webserver\",\"-import\",\"\/var\/hoverfly\/simulation.json\")\n...<\/pre>\n<p>Technically we can say we are ready to go and connect to the container, however when running test containers the container is not accessible through the port specified to do the binding. After all, if tests run on parallel there is going to be a collision. So what Testcontainers do is to map the exposed port of the container to a random local port.<br \/>This way port collisions are avoided.<\/p>\n<pre class=\"wp-block-preformatted brush:java\">@Test\n\tvoid testHttpGet() {\n\t\tvar hoverFlyHost = gcs.getHost();\n\t\tvar hoverFlyPort = gcs.getMappedPort(8500);\n\t\tvar client = HttpClient.newHttpClient();\n\t\tvar request = HttpRequest.newBuilder()\n\t\t\t\t.uri(URI.create(\"http:\/\/\"+hoverFlyHost+\":\"+ hoverFlyPort +\"\/user\"))\n\t\t\t\t.build();\n\t\tvar res = client.sendAsync(request, HttpResponse.BodyHandlers.ofString())\n\t\t\t\t.thenApply(HttpResponse::body)\n\t\t\t\t.join();\n\t\tAssertions.assertEquals(\"{\\\"username\\\":\\\"test-user\\\"}\",res);\n\t}<\/pre>\n<p>Using GenericContainer.getMappedPort(8500) we can get the port we have to use to interact with the container. Also getHost() is essential too since it <a href=\"https:\/\/bsideup.github.io\/posts\/testcontainers_fixed_ports\/\">won\u2019t always<\/a> direct to localhost.<\/p>\n<p>Last but not least while testing if your are curious enough and do a docker ps.<\/p>\n<pre class=\"wp-block-preformatted brush:java\">docker ps \n&gt;04a322447226        testcontainers\/ryuk:0.3.0   \"\/app\"                   3 seconds ago       Up 2 seconds        0.0.0.0:32814-&gt;8080\/tcp    testcontainers-ryuk-fb60c3c6-5f31-4f4e-9ab7-ce25a00eeccc<\/pre>\n<p>You shall see a container running which is not the one we instructed through our unit test. The ryuk container is responsible for removing containers\/networks\/volumes\/images by given filter after specified delay.<\/p>\n<p>That\u2019s it! We just achieved running the container we needed through our a test and we successfully migrated a previous test to one using test containers.<\/p>\n<div class=\"attribution\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>Published on Java Code Geeks with permission by Emmanouil Gkatziouras, partner at our <a href=\"\/\/www.javacodegeeks.com\/join-us\/jcg\/\" target=\"_blank\" rel=\"noopener\">JCG program<\/a>. See the original article here: <a href=\"https:\/\/egkatzioura.com\/2020\/12\/09\/testing-using-testcontainers\/\" target=\"_blank\" rel=\"noopener\">Testing using TestContainers<\/a><\/p>\n<p>Opinions expressed by Java Code Geeks contributors are their own.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Part of our everyday ci\/cd tasks involve using containers in order for the tests to take effect.So what if you could control the containers you use through your tests and serve your scenarios better.Also what if you could do this in a more managed way? Testcontainers is a Java library that supports JUnit tests, providing &hellip;<\/p>\n","protected":false},"author":936,"featured_media":112,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[936,1582,670,273],"class_list":["post-108081","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-docker","tag-hoverfly","tag-maven","tag-testing"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Testing using TestContainers - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Part of our everyday ci\/cd tasks involve using containers in order for the tests to take effect.So what if you could control the containers you use\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2020\/12\/testing-using-testcontainers.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Testing using TestContainers - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Part of our everyday ci\/cd tasks involve using containers in order for the tests to take effect.So what if you could control the containers you use\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2020\/12\/testing-using-testcontainers.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2020-12-23T05:00:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Emmanouil Gkatziouras\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Emmanouil Gkatziouras\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2020\\\/12\\\/testing-using-testcontainers.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2020\\\/12\\\/testing-using-testcontainers.html\"},\"author\":{\"name\":\"Emmanouil Gkatziouras\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/5eee031b356c7682e1fd24c8297561c6\"},\"headline\":\"Testing using TestContainers\",\"datePublished\":\"2020-12-23T05:00:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2020\\\/12\\\/testing-using-testcontainers.html\"},\"wordCount\":546,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2020\\\/12\\\/testing-using-testcontainers.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/enterprise-java-logo.jpg\",\"keywords\":[\"Docker\",\"Hoverfly\",\"Maven\",\"Testing\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2020\\\/12\\\/testing-using-testcontainers.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2020\\\/12\\\/testing-using-testcontainers.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2020\\\/12\\\/testing-using-testcontainers.html\",\"name\":\"Testing using TestContainers - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2020\\\/12\\\/testing-using-testcontainers.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2020\\\/12\\\/testing-using-testcontainers.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/enterprise-java-logo.jpg\",\"datePublished\":\"2020-12-23T05:00:00+00:00\",\"description\":\"Part of our everyday ci\\\/cd tasks involve using containers in order for the tests to take effect.So what if you could control the containers you use\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2020\\\/12\\\/testing-using-testcontainers.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2020\\\/12\\\/testing-using-testcontainers.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2020\\\/12\\\/testing-using-testcontainers.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/enterprise-java-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/enterprise-java-logo.jpg\",\"width\":150,\"height\":150,\"caption\":\"java-interview-questions-answers\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2020\\\/12\\\/testing-using-testcontainers.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Testing using TestContainers\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/5eee031b356c7682e1fd24c8297561c6\",\"name\":\"Emmanouil Gkatziouras\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5c6d031d211ab786ec335687ad6f3f076f93f47e24c92d78041d2f805ee6c291?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5c6d031d211ab786ec335687ad6f3f076f93f47e24c92d78041d2f805ee6c291?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5c6d031d211ab786ec335687ad6f3f076f93f47e24c92d78041d2f805ee6c291?s=96&d=mm&r=g\",\"caption\":\"Emmanouil Gkatziouras\"},\"description\":\"He is a versatile software engineer with experience in a wide variety of applications\\\/services.He is enthusiastic about new projects, embracing new technologies, and getting to know people in the field of software.\",\"sameAs\":[\"http:\\\/\\\/egkatzioura.wordpress.com\\\/\",\"https:\\\/\\\/gr.linkedin.com\\\/in\\\/gkatziourasemmanouil\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/emmanouil-gkatziouras\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Testing using TestContainers - Java Code Geeks","description":"Part of our everyday ci\/cd tasks involve using containers in order for the tests to take effect.So what if you could control the containers you use","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2020\/12\/testing-using-testcontainers.html","og_locale":"en_US","og_type":"article","og_title":"Testing using TestContainers - Java Code Geeks","og_description":"Part of our everyday ci\/cd tasks involve using containers in order for the tests to take effect.So what if you could control the containers you use","og_url":"https:\/\/www.javacodegeeks.com\/2020\/12\/testing-using-testcontainers.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2020-12-23T05:00:00+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","type":"image\/jpeg"}],"author":"Emmanouil Gkatziouras","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Emmanouil Gkatziouras","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2020\/12\/testing-using-testcontainers.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2020\/12\/testing-using-testcontainers.html"},"author":{"name":"Emmanouil Gkatziouras","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/5eee031b356c7682e1fd24c8297561c6"},"headline":"Testing using TestContainers","datePublished":"2020-12-23T05:00:00+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2020\/12\/testing-using-testcontainers.html"},"wordCount":546,"commentCount":0,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2020\/12\/testing-using-testcontainers.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","keywords":["Docker","Hoverfly","Maven","Testing"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2020\/12\/testing-using-testcontainers.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2020\/12\/testing-using-testcontainers.html","url":"https:\/\/www.javacodegeeks.com\/2020\/12\/testing-using-testcontainers.html","name":"Testing using TestContainers - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2020\/12\/testing-using-testcontainers.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2020\/12\/testing-using-testcontainers.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","datePublished":"2020-12-23T05:00:00+00:00","description":"Part of our everyday ci\/cd tasks involve using containers in order for the tests to take effect.So what if you could control the containers you use","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2020\/12\/testing-using-testcontainers.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2020\/12\/testing-using-testcontainers.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2020\/12\/testing-using-testcontainers.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","width":150,"height":150,"caption":"java-interview-questions-answers"},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2020\/12\/testing-using-testcontainers.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"Testing using TestContainers"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/5eee031b356c7682e1fd24c8297561c6","name":"Emmanouil Gkatziouras","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/5c6d031d211ab786ec335687ad6f3f076f93f47e24c92d78041d2f805ee6c291?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/5c6d031d211ab786ec335687ad6f3f076f93f47e24c92d78041d2f805ee6c291?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/5c6d031d211ab786ec335687ad6f3f076f93f47e24c92d78041d2f805ee6c291?s=96&d=mm&r=g","caption":"Emmanouil Gkatziouras"},"description":"He is a versatile software engineer with experience in a wide variety of applications\/services.He is enthusiastic about new projects, embracing new technologies, and getting to know people in the field of software.","sameAs":["http:\/\/egkatzioura.wordpress.com\/","https:\/\/gr.linkedin.com\/in\/gkatziourasemmanouil"],"url":"https:\/\/www.javacodegeeks.com\/author\/emmanouil-gkatziouras"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/108081","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/936"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=108081"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/108081\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/112"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=108081"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=108081"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=108081"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}