{"id":42751421,"url":"https://github.com/bazhenov/docker-testng-integration","last_synced_at":"2026-01-29T19:34:03.079Z","repository":{"id":10825365,"uuid":"67128782","full_name":"bazhenov/docker-testng-integration","owner":"bazhenov","description":"Simple way of running integration tests with TestNG and Docker","archived":false,"fork":false,"pushed_at":"2023-04-17T11:04:53.000Z","size":101,"stargazers_count":4,"open_issues_count":4,"forks_count":9,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-26T21:22:15.071Z","etag":null,"topics":["docker","docker-testng","java","testng"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bazhenov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-01T12:23:01.000Z","updated_at":"2022-06-08T14:24:24.000Z","dependencies_parsed_at":"2023-01-11T17:57:39.724Z","dependency_job_id":null,"html_url":"https://github.com/bazhenov/docker-testng-integration","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/bazhenov/docker-testng-integration","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bazhenov%2Fdocker-testng-integration","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bazhenov%2Fdocker-testng-integration/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bazhenov%2Fdocker-testng-integration/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bazhenov%2Fdocker-testng-integration/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bazhenov","download_url":"https://codeload.github.com/bazhenov/docker-testng-integration/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bazhenov%2Fdocker-testng-integration/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28883091,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-29T19:23:39.025Z","status":"ssl_error","status_checked_at":"2026-01-29T19:22:11.631Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","docker-testng","java","testng"],"created_at":"2026-01-29T19:34:03.011Z","updated_at":"2026-01-29T19:34:03.066Z","avatar_url":"https://github.com/bazhenov.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Docker TestNG Integration\n\n## Introduction\n\nThis library allows you to run Docker containers before your test suite.\n\n## Usage\n\nInclude dependency in your `pom.xml`\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003eme.bazhenov\u003c/groupId\u003e\n  \u003cartifactId\u003edocker-testng-integration\u003c/artifactId\u003e\n  \u003cversion\u003e1.6\u003c/version\u003e\n  \u003cscope\u003etest\u003c/scope\u003e\n\u003c/dependency\u003e\n```\n\nThen in your test use class-level annotation `@Container` (you can provide several annotations), as well as method-level\nannotation `@AfterContainerStart`. You also need to register `me.bazhenov.docker.DockerTestNgListener`\n\n```java\n@Container(name = \"my-container\", image = \"mysql\", publish = @Port(3306), environment =\n  {\"MYSQL_ROOT_PASSWORD=secret\"})\n@Listeners(DockerTestNgListener.class)\npublic class MySqlIT {\n\n  private int mysqlPort;\n\n  @AfterContainerStart\n  public void setUp(@ContainerPort(name = \"my-container\", port = 3306) int port) {\n    mysqlPort = port;\n  }\n\n  @Test\n  public void myTest() {\n    String jdbcUrl = \"jdbc:mysql://localhost:\" + mysqlPort + \"/db\";\n    // Using this URL to connect to MySQL\n  }\n}\n```\n\nIf you don't want to register listener on a test-case class you can add the listener to your test suite. If you are\nusing Maven, just add following config to your `pom.xml`:\n\n```xml\n\u003cbuild\u003e\n  \u003cplugins\u003e\n    \u003cplugin\u003e\n      \u003cgroupId\u003eorg.apache.maven.plugins\u003c/groupId\u003e\n      \u003cartifactId\u003emaven-surefire-plugin\u003c/artifactId\u003e\n      \u003cconfiguration\u003e\n        \u003cproperties\u003e\n          \u003cproperty\u003e\n            \u003cname\u003elistener\u003c/name\u003e\n            \u003cvalue\u003eme.bazhenov.docker.DockerTestNgListener\u003c/value\u003e\n          \u003c/property\u003e\n        \u003c/properties\u003e\n      \u003c/configuration\u003e\n    \u003c/plugin\u003e\n  \u003c/plugins\u003e\n\u003c/build\u003e\n```\n\nYou should remember that registering listener both in XML and test classes (using annotations) will result in container being\nstarted twice.\n\nBy default all containers are local to the test case. So if you define two test cases with container named `mysql`, 2 mysql \ninstances will be started. One for each test case. But you can share containers between test cases, if you need to.\n\n```java\n@Container(image = \"mysql:5.6\", name = \"mysql\", publish = @Port(3306))\nclass SharedContainers {}\n\n@ContainersFrom(SharedContainers.class)\n@Listeners(DockerTestNgListener.class)\nclass MyTestCase {\n\n  @AfterContainerStart\n  public void dockerSetup(@ContainerPort(name = \"mysql\", port = 3306) int mysqlPort) {\n    // ...\n  }\n}\n```\n\nIn this case container `mysql` will be started just once and shared between all test cases importing it using `@ContainersFrom`.\n\n## Networking\n\nYou can create network between several containers:\n\n```java\n@Container(name = \"mysql\", image = \"mysql\", network = \"my-test-network\", networkAlias = \"mysql-host\")\n@Container(name = \"node1\", image = \"node-needs-mysql\", network = \"my-test-network\", environment =\n\t{\"NODE_JDBC_URL=jdbc:mysql://mysql-host:3306/db\"})\n@Container(name = \"node2\", image = \"node-needs-mysql\", network = \"my-test-network\", environment =\n\t{\"NODE_JDBC_URL=jdbc:mysql://mysql-host:3306/db\"})\n@Listeners(DockerTestNgListener.class)\npublic class MyAppIT {\n  // ...\n}\n```\n\nContainers `mysql`, `node1` and `node2` will be started with the same network `my-test-network`.\nContainer `mysql` will be accessible in this network by network alias `mysql-host` with all its ports.\nPort publishing is not necessary.\n\n## Features\n\n* library using `docker` command line utility;\n* provides an easy way of getting dynamically allocated ports in tests;\n* mark all containers with `testng` label, so they could be easily found with `docker ps -af label=testng` command;\n* can map host directories as volumes inside a container;\n* waits for given ports to be open in a container, so containerized service is up at the moment of test starts;\n* library can share containers before several test cases using `@ContainersFrom` annotation. This allows to speed up test\nexecution if you can reuse single container instead of starting a new container each time.\n\n## Limitations\n\n* only TCP ports are exposed at the moment\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbazhenov%2Fdocker-testng-integration","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbazhenov%2Fdocker-testng-integration","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbazhenov%2Fdocker-testng-integration/lists"}