{"id":1048,"date":"2026-03-24T23:44:59","date_gmt":"2026-03-25T02:44:59","guid":{"rendered":"https:\/\/www.isacaguiar.com.br\/blog\/?p=1048"},"modified":"2026-03-24T23:58:44","modified_gmt":"2026-03-25T02:58:44","slug":"github-actions-java-maven-ci-tests-2","status":"publish","type":"post","link":"http:\/\/www.isacaguiar.com.br\/blog\/en\/github-actions-java-maven-ci-tests-2\/","title":{"rendered":"CI with GitHub Actions for Java: Running Unit Tests with Maven Step by Step"},"content":{"rendered":"<h2 data-section-id=\"1mky8z6\" data-start=\"360\" data-end=\"378\">\ud83e\udde9 Introduction<\/h2>\n<p data-start=\"380\" data-end=\"592\">Automating tests is one of the key pillars of quality in modern software systems. In Java projects using Spring Boot, ensuring that unit tests run on every change is essential to maintain application reliability.<\/p>\n<p data-start=\"594\" data-end=\"746\">In this article, we will configure a simple <strong data-start=\"638\" data-end=\"669\">CI (Continuous Integration)<\/strong> pipeline using <strong data-start=\"685\" data-end=\"703\">GitHub Actions<\/strong>, focused on running unit tests with Maven.<\/p>\n<p data-start=\"748\" data-end=\"851\">We will use as an example a project based on <strong data-start=\"793\" data-end=\"823\">Domain Driven Design (DDD)<\/strong> with Java 21 and MapStruct.<\/p>\n<h2 data-section-id=\"1xjb5pb\" data-start=\"858\" data-end=\"887\">\ud83d\ude80 What is GitHub Actions?<\/h2>\n<p data-start=\"889\" data-end=\"1002\"><strong data-start=\"889\" data-end=\"907\">GitHub Actions<\/strong> is a native GitHub tool that allows you to automate workflows directly within your repository.<\/p>\n<p data-start=\"1004\" data-end=\"1021\">With it, you can:<\/p>\n<ul data-start=\"1023\" data-end=\"1133\">\n<li data-section-id=\"10z86gx\" data-start=\"1023\" data-end=\"1050\">Automatically run tests<\/li>\n<li data-section-id=\"cqleb9\" data-start=\"1051\" data-end=\"1077\">Build your application<\/li>\n<li data-section-id=\"144ehks\" data-start=\"1078\" data-end=\"1099\">Publish artifacts<\/li>\n<li data-section-id=\"8uhrdb\" data-start=\"1100\" data-end=\"1133\">Integrate with external tools<\/li>\n<\/ul>\n<p data-start=\"1135\" data-end=\"1192\">All triggered by events such as <code data-start=\"1167\" data-end=\"1173\">push<\/code> or <code data-start=\"1177\" data-end=\"1191\">pull request<\/code>.<\/p>\n<h2 data-section-id=\"1m1dwm9\" data-start=\"1199\" data-end=\"1223\">\ud83c\udfd7\ufe0f Project structure<\/h2>\n<p data-start=\"1225\" data-end=\"1261\">Our project is organized as follows:<\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>website-projects\/\r\n\u2514\u2500 ddd-java-spring-dto-model-entity\/\r\n\u251c\u2500 pom.xml\r\n\u2514\u2500 src\/<\/code><\/pre>\n<\/div>\n<h2 data-section-id=\"1jrktcg\" data-start=\"1357\" data-end=\"1399\">\u2699\ufe0f Creating the GitHub Actions workflow<\/h2>\n<p data-start=\"1401\" data-end=\"1457\">To configure the pipeline, we create the following file:<\/p>\n<div class=\"relative w-full mt-4 mb-1\">\n<div class=\"\">\n<div class=\"relative\">\n<div class=\"h-full min-h-0 min-w-0\">\n<div class=\"h-full min-h-0 min-w-0\">\n<div class=\"border border-token-border-light border-radius-3xl corner-superellipse\/1.1 rounded-3xl\">\n<div class=\"h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse\/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback\">\n<div class=\"pe-11 pt-3\">\n<div class=\"relative z-0 flex max-w-full\">\n<div id=\"code-block-viewer\" dir=\"ltr\" class=\"q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch \u037ck \u037cy\">\n<div class=\"cm-scroller\">\n<div class=\"cm-content q9tKkq_readonly\">\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>.github\/workflows\/java-tests.yml<\/code><\/pre>\n<\/div>\n<h2 data-start=\"1501\" data-end=\"1556\"><\/h2>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<h2 data-section-id=\"6nn13h\" data-start=\"1506\" data-end=\"1531\">\ud83d\udcc4 GitHub Actions YAML<\/h2>\n<div class=\"relative w-full mt-4 mb-1\">\n<div class=\"\">\n<div class=\"relative\">\n<div class=\"h-full min-h-0 min-w-0\">\n<div class=\"h-full min-h-0 min-w-0\">\n<div class=\"border border-token-border-light border-radius-3xl corner-superellipse\/1.1 rounded-3xl\">\n<div class=\"h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse\/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback\">\n<div class=\"\">\n<div class=\"relative z-0 flex max-w-full\">\n<div id=\"code-block-viewer\" dir=\"ltr\" class=\"q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch \u037ck \u037cy\">\n<div class=\"cm-scroller\">\n<div class=\"cm-content q9tKkq_readonly\">\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-yaml\" data-lang=\"YAML\"><code>name: Java Unit Tests\r\n\r\non:\r\n  push:\r\n    branches: [ \"main\" ]\r\n    paths:\r\n      - \"ddd-java-spring-dto-model-entity\/**\"\r\n      - \".github\/workflows\/java-tests.yml\"\r\n\r\n  pull_request:\r\n    branches: [ \"main\" ]\r\n    paths:\r\n      - \"ddd-java-spring-dto-model-entity\/**\"\r\n      - \".github\/workflows\/java-tests.yml\"\r\n\r\njobs:\r\n  test:\r\n    runs-on: ubuntu-latest\r\n\r\n    defaults:\r\n      run:\r\n        working-directory: ddd-java-spring-dto-model-entity\r\n\r\n    steps:\r\n      - name: Checkout do c\u00f3digo\r\n        uses: actions\/checkout@v4\r\n\r\n      - name: Configurar Java 21\r\n        uses: actions\/setup-java@v5\r\n        with:\r\n          distribution: temurin\r\n          java-version: '21'\r\n          cache: maven\r\n\r\n      - name: Executar testes unit\u00e1rios\r\n        run: mvn -B test<\/code><\/pre>\n<\/div>\n<h2 data-section-id=\"30dlba\" data-start=\"2396\" data-end=\"2423\"><\/h2>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<h2 data-section-id=\"n554wb\" data-start=\"2280\" data-end=\"2304\">\ud83d\udd0d Workflow breakdown<\/h2>\n<h3 data-section-id=\"ktm205\" data-start=\"2306\" data-end=\"2317\">\ud83d\udd39 name<\/h3>\n<div class=\"relative w-full mt-4 mb-1\">\n<div class=\"\">\n<div class=\"relative\">\n<div class=\"h-full min-h-0 min-w-0\">\n<div class=\"h-full min-h-0 min-w-0\">\n<div class=\"border border-token-border-light border-radius-3xl corner-superellipse\/1.1 rounded-3xl\">\n<div class=\"h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse\/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback\">\n<div class=\"\">\n<div class=\"relative z-0 flex max-w-full\">\n<div id=\"code-block-viewer\" dir=\"ltr\" class=\"q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch \u037ck \u037cy\">\n<div class=\"cm-scroller\">\n<div class=\"cm-content q9tKkq_readonly\">\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-yaml\" data-lang=\"YAML\"><code>name: Java Unit Tests<\/code><\/pre>\n<\/div>\n<p>Defines the name displayed in GitHub Actions.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<h3 data-section-id=\"1w402dl\" data-start=\"2406\" data-end=\"2426\">\ud83d\udd39 on (triggers)<\/h3>\n<div class=\"relative w-full mt-4 mb-1\">\n<div class=\"\">\n<div class=\"relative\">\n<div class=\"h-full min-h-0 min-w-0\">\n<div class=\"h-full min-h-0 min-w-0\">\n<div class=\"border border-token-border-light border-radius-3xl corner-superellipse\/1.1 rounded-3xl\">\n<div class=\"h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse\/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback\">\n<div class=\"pointer-events-none absolute inset-x-4 top-12 bottom-4\">\n<div class=\"pointer-events-none sticky z-40 shrink-0 z-1!\">\n<div class=\"sticky bg-token-border-light\">\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-yaml\" data-lang=\"YAML\"><code>on:\r\n  push:\r\n  pull_request:<\/code><\/pre>\n<\/div>\n<p data-start=\"2587\" data-end=\"2620\">The workflow runs when:<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<ul data-start=\"2494\" data-end=\"2573\">\n<li data-section-id=\"1ug6owt\" data-start=\"2494\" data-end=\"2533\">code is pushed to the <code data-start=\"2518\" data-end=\"2524\">main<\/code> branch<\/li>\n<li data-section-id=\"1o0w22i\" data-start=\"2534\" data-end=\"2573\">a pull request is opened or updated<\/li>\n<\/ul>\n<h3 data-section-id=\"679s56\" data-start=\"2580\" data-end=\"2617\">\ud83d\udd39 paths (important optimization)<\/h3>\n<div class=\"relative w-full mt-4 mb-1\">\n<div class=\"\">\n<div class=\"relative\">\n<div class=\"h-full min-h-0 min-w-0\">\n<div class=\"h-full min-h-0 min-w-0\">\n<div class=\"border border-token-border-light border-radius-3xl corner-superellipse\/1.1 rounded-3xl\">\n<div class=\"h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse\/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback\">\n<div class=\"pointer-events-none absolute inset-x-4 top-12 bottom-4\">\n<div class=\"pointer-events-none sticky z-40 shrink-0 z-1!\">\n<div class=\"sticky bg-token-border-light\">\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-yaml\" data-lang=\"YAML\"><code>paths:\r\n  - \"ddd-java-spring-dto-model-entity\/**\"<\/code><\/pre>\n<\/div>\n<p data-start=\"2785\" data-end=\"2883\">\ud83d\udc49 Ensures the pipeline runs <strong data-start=\"2710\" data-end=\"2759\">only when changes occur in the project folder<\/strong>, avoiding unnecessary executions.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<h3 data-section-id=\"ktiuhi\" data-start=\"2800\" data-end=\"2811\">\ud83d\udd39 jobs<\/h3>\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-yaml\" data-lang=\"YAML\"><code>jobs:\r\n  test:\r\n    runs-on: ubuntu-latest<\/code><\/pre>\n<\/div>\n<p data-start=\"2867\" data-end=\"2910\">Defines a job that runs on a Linux machine.<\/p>\n<h3 data-section-id=\"vv9sl9\" data-start=\"2917\" data-end=\"2953\">\ud83d\udd39 working-directory (key point)<\/h3>\n<div class=\"relative w-full mt-4 mb-1\">\n<div class=\"\">\n<div class=\"relative\">\n<div class=\"h-full min-h-0 min-w-0\">\n<div class=\"h-full min-h-0 min-w-0\">\n<div class=\"border border-token-border-light border-radius-3xl corner-superellipse\/1.1 rounded-3xl\">\n<div class=\"h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse\/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback\">\n<div class=\"pointer-events-none absolute inset-x-4 top-12 bottom-4\">\n<div class=\"pointer-events-none sticky z-40 shrink-0 z-1!\">\n<div class=\"sticky bg-token-border-light\">\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-yaml\" data-lang=\"YAML\"><code>defaults:\r\n  run:\r\n    working-directory: ddd-java-spring-dto-model-entity<\/code><\/pre>\n<\/div>\n<p data-start=\"3153\" data-end=\"3180\">\ud83d\udc49 This is critical:<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p data-start=\"3063\" data-end=\"3183\">Since the project is inside a subdirectory, we define the working directory so Maven can correctly locate the <code data-start=\"3173\" data-end=\"3182\">pom.xml<\/code>.<\/p>\n<h3 data-section-id=\"1p1ipsa\" data-start=\"3190\" data-end=\"3205\">\ud83d\udd39 checkout<\/h3>\n<div class=\"relative w-full mt-4 mb-1\">\n<div class=\"\">\n<div class=\"relative\">\n<div class=\"h-full min-h-0 min-w-0\">\n<div class=\"h-full min-h-0 min-w-0\">\n<div class=\"border border-token-border-light border-radius-3xl corner-superellipse\/1.1 rounded-3xl\">\n<div class=\"h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse\/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback\">\n<div class=\"pointer-events-none absolute inset-x-4 top-12 bottom-4\">\n<div class=\"pointer-events-none sticky z-40 shrink-0 z-1!\">\n<div class=\"sticky bg-token-border-light\">\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-yaml\" data-lang=\"YAML\"><code>- uses: actions\/checkout@v4<\/code><\/pre>\n<\/div>\n<p data-start=\"3410\" data-end=\"3458\">Clones the repository into the runner.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<h3 data-section-id=\"17o10s9\" data-start=\"3293\" data-end=\"3310\">\ud83d\udd39 Java setup<\/h3>\n<div class=\"relative w-full mt-4 mb-1\">\n<div class=\"\">\n<div class=\"relative\">\n<div class=\"h-full min-h-0 min-w-0\">\n<div class=\"h-full min-h-0 min-w-0\">\n<div class=\"border border-token-border-light border-radius-3xl corner-superellipse\/1.1 rounded-3xl\">\n<div class=\"h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse\/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback\">\n<div class=\"pointer-events-none absolute inset-x-4 top-12 bottom-4\">\n<div class=\"pointer-events-none sticky z-40 shrink-0 z-1!\">\n<div class=\"sticky bg-token-border-light\">\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-yaml\" data-lang=\"YAML\"><code>- uses: actions\/setup-java@v5<\/code><\/pre>\n<\/div>\n<p data-start=\"3527\" data-end=\"3537\">Configures:<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<ul data-start=\"3368\" data-end=\"3408\">\n<li data-section-id=\"mxxbsn\" data-start=\"3368\" data-end=\"3379\">Java 21<\/li>\n<li data-section-id=\"skl5un\" data-start=\"3380\" data-end=\"3408\">Maven dependency caching<\/li>\n<\/ul>\n<p data-start=\"3410\" data-end=\"3459\">\ud83d\udc49 This significantly improves build performance.<\/p>\n<h3 data-section-id=\"1gvsbnk\" data-start=\"3466\" data-end=\"3486\">\ud83d\udd39 Running tests<\/h3>\n<div class=\"relative w-full mt-4 mb-1\">\n<div class=\"\">\n<div class=\"relative\">\n<div class=\"h-full min-h-0 min-w-0\">\n<div class=\"h-full min-h-0 min-w-0\">\n<div class=\"border border-token-border-light border-radius-3xl corner-superellipse\/1.1 rounded-3xl\">\n<div class=\"h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse\/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback\">\n<div class=\"\">\n<div class=\"relative z-0 flex max-w-full\">\n<div id=\"code-block-viewer\" dir=\"ltr\" class=\"q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch \u037ck \u037cy\">\n<div class=\"cm-scroller\">\n<div class=\"cm-content q9tKkq_readonly\">\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-yaml\" data-lang=\"YAML\"><code>run: mvn -B test<\/code><\/pre>\n<\/div>\n<p data-start=\"3690\" data-end=\"3718\">Runs unit tests.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<ul data-start=\"3536\" data-end=\"3576\">\n<li data-section-id=\"1r82m0f\" data-start=\"3536\" data-end=\"3576\"><code data-start=\"3538\" data-end=\"3542\">-B<\/code> \u2192 batch mode (recommended for CI)<\/li>\n<\/ul>\n<h2 data-section-id=\"bmk6ng\" data-start=\"3583\" data-end=\"3602\">\ud83d\udd04 Pipeline flow<\/h2>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.isacaguiar.com.br\/blog\/wp-content\/uploads\/2026\/03\/mermaid-diagram-4.png\" alt=\"GitHub Actions Java Maven unit tests\" width=\"740\" height=\"44\" class=\"wp-image-1050 aligncenter\" srcset=\"http:\/\/www.isacaguiar.com.br\/blog\/wp-content\/uploads\/2026\/03\/mermaid-diagram-4.png 2165w, http:\/\/www.isacaguiar.com.br\/blog\/wp-content\/uploads\/2026\/03\/mermaid-diagram-4-400x24.png 400w, http:\/\/www.isacaguiar.com.br\/blog\/wp-content\/uploads\/2026\/03\/mermaid-diagram-4-1024x61.png 1024w, http:\/\/www.isacaguiar.com.br\/blog\/wp-content\/uploads\/2026\/03\/mermaid-diagram-4-768x46.png 768w, http:\/\/www.isacaguiar.com.br\/blog\/wp-content\/uploads\/2026\/03\/mermaid-diagram-4-1536x92.png 1536w, http:\/\/www.isacaguiar.com.br\/blog\/wp-content\/uploads\/2026\/03\/mermaid-diagram-4-2048x123.png 2048w\" sizes=\"auto, (max-width: 740px) 100vw, 740px\" \/><\/p>\n<p>GitHub Actions Java Maven unit tests<\/p>\n<h2 data-section-id=\"1wq1skx\" data-start=\"3771\" data-end=\"3791\">\ud83d\udca1 Best practices<\/h2>\n<ul data-start=\"3793\" data-end=\"3953\">\n<li data-section-id=\"1uead04\" data-start=\"3793\" data-end=\"3840\">\u2714\ufe0f Use dependency caching (already applied)<\/li>\n<li data-section-id=\"chhwss\" data-start=\"3841\" data-end=\"3877\">\u2714\ufe0f Limit execution using <code data-start=\"3868\" data-end=\"3875\">paths<\/code><\/li>\n<li data-section-id=\"1po2o3y\" data-start=\"3878\" data-end=\"3912\">\u2714\ufe0f Fix Java version (e.g., 21)<\/li>\n<li data-section-id=\"1wjz50y\" data-start=\"3913\" data-end=\"3953\">\u2714\ufe0f Keep the pipeline simple at first<\/li>\n<\/ul>\n<h2 data-section-id=\"1mbmy1n\" data-start=\"3960\" data-end=\"3987\">\ud83d\udd25 Possible improvements<\/h2>\n<p data-start=\"3989\" data-end=\"4029\">You can evolve this pipeline to include:<\/p>\n<ul data-start=\"4031\" data-end=\"4136\">\n<li data-section-id=\"rssmc5\" data-start=\"4031\" data-end=\"4063\">\ud83d\udcca Code coverage with JaCoCo<\/li>\n<li data-section-id=\"1f35yp3\" data-start=\"4064\" data-end=\"4088\">\ud83e\uddea Integration tests<\/li>\n<li data-section-id=\"1e80o2s\" data-start=\"4089\" data-end=\"4108\">\ud83d\udc33 Docker build<\/li>\n<li data-section-id=\"x1s6p\" data-start=\"4109\" data-end=\"4136\">\ud83d\ude80 Automatic deployment<\/li>\n<\/ul>\n<h2 data-section-id=\"bgkthu\" data-start=\"4143\" data-end=\"4164\">\ud83d\udd17 Example project<\/h2>\n<p data-start=\"4166\" data-end=\"4215\">\ud83d\udc49 <a data-start=\"4169\" data-end=\"4215\" rel=\"noopener\" target=\"_new\" class=\"decorated-link\" href=\"https:\/\/github.com\/isacaguiar\/website-projects\">https:\/\/github.com\/isacaguiar\/website-projects<span aria-hidden=\"true\" class=\"ms-0.5 inline-block align-middle leading-none\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20\" height=\"20\" aria-hidden=\"true\" data-rtl-flip=\"\" class=\"block h-[0.75em] w-[0.75em] stroke-current stroke-[0.75]\"><use href=\"\/cdn\/assets\/sprites-core-cohbnghc.svg#304883\" fill=\"currentColor\"><\/use><\/svg><\/span><\/a><\/p>\n<h2 data-section-id=\"j3x6g\" data-start=\"4222\" data-end=\"4238\">\ud83e\udde0 Conclusion<\/h2>\n<p data-start=\"4240\" data-end=\"4317\">With just a few steps, we created an efficient CI pipeline for Java projects.<\/p>\n<p data-start=\"4319\" data-end=\"4333\">This approach:<\/p>\n<ul data-start=\"4335\" data-end=\"4434\">\n<li data-section-id=\"1ixju2p\" data-start=\"4335\" data-end=\"4360\">improves code quality<\/li>\n<li data-section-id=\"twoeqa\" data-start=\"4361\" data-end=\"4390\">reduces production issues<\/li>\n<li data-section-id=\"17miqus\" data-start=\"4391\" data-end=\"4434\">makes your repository more professional<\/li>\n<\/ul>\n<p data-start=\"4436\" data-end=\"4496\">And best of all: everything is fully integrated into GitHub.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\ud83e\udde9 Introduction Automating tests is one of the key pillars of quality in modern software systems. In Java projects using Spring Boot,\u2026<\/p>\n","protected":false},"author":1,"featured_media":1052,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[346],"tags":[],"class_list":["post-1048","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>CI with GitHub Actions for Java: Running Unit Tests with Maven Step by Step<\/title>\n<meta name=\"description\" content=\"Learn how to set up CI with GitHub Actions for Java projects using Maven to run automated unit tests with a step-by-step guide.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/www.isacaguiar.com.br\/blog\/en\/github-actions-java-maven-ci-tests-2\/\" \/>\n<meta property=\"og:locale\" content=\"pt_BR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"CI with GitHub Actions for Java: Running Unit Tests with Maven Step by Step\" \/>\n<meta property=\"og:description\" content=\"Learn how to set up CI with GitHub Actions for Java projects using Maven to run automated unit tests with a step-by-step guide.\" \/>\n<meta property=\"og:url\" content=\"http:\/\/www.isacaguiar.com.br\/blog\/en\/github-actions-java-maven-ci-tests-2\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog do Aguiar\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/isac.velozo.aguiar\" \/>\n<meta property=\"article:published_time\" content=\"2026-03-25T02:44:59+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-03-25T02:58:44+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.isacaguiar.com.br\/blog\/wp-content\/uploads\/2026\/03\/ChatGPT-Image-Mar-24-2026-11_41_56-PM-1-1024x683.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1024\" \/>\n\t<meta property=\"og:image:height\" content=\"683\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"isacaguiar\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Escrito por\" \/>\n\t<meta name=\"twitter:data1\" content=\"isacaguiar\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. tempo de leitura\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutos\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"http:\/\/www.isacaguiar.com.br\/blog\/en\/github-actions-java-maven-ci-tests-2\/#article\",\"isPartOf\":{\"@id\":\"http:\/\/www.isacaguiar.com.br\/blog\/en\/github-actions-java-maven-ci-tests-2\/\"},\"author\":{\"name\":\"isacaguiar\",\"@id\":\"http:\/\/www.isacaguiar.com.br\/blog\/#\/schema\/person\/78719359439f068d8b1e5e0bcb9d934d\"},\"headline\":\"CI with GitHub Actions for Java: Running Unit Tests with Maven Step by Step\",\"datePublished\":\"2026-03-25T02:44:59+00:00\",\"dateModified\":\"2026-03-25T02:58:44+00:00\",\"mainEntityOfPage\":{\"@id\":\"http:\/\/www.isacaguiar.com.br\/blog\/en\/github-actions-java-maven-ci-tests-2\/\"},\"wordCount\":361,\"image\":{\"@id\":\"http:\/\/www.isacaguiar.com.br\/blog\/en\/github-actions-java-maven-ci-tests-2\/#primaryimage\"},\"thumbnailUrl\":\"http:\/\/www.isacaguiar.com.br\/blog\/wp-content\/uploads\/2026\/03\/ChatGPT-Image-Mar-24-2026-11_41_56-PM-1.png\",\"articleSection\":[\"Technology\"],\"inLanguage\":\"pt-BR\"},{\"@type\":\"WebPage\",\"@id\":\"http:\/\/www.isacaguiar.com.br\/blog\/en\/github-actions-java-maven-ci-tests-2\/\",\"url\":\"http:\/\/www.isacaguiar.com.br\/blog\/en\/github-actions-java-maven-ci-tests-2\/\",\"name\":\"CI with GitHub Actions for Java: Running Unit Tests with Maven Step by Step\",\"isPartOf\":{\"@id\":\"http:\/\/www.isacaguiar.com.br\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"http:\/\/www.isacaguiar.com.br\/blog\/en\/github-actions-java-maven-ci-tests-2\/#primaryimage\"},\"image\":{\"@id\":\"http:\/\/www.isacaguiar.com.br\/blog\/en\/github-actions-java-maven-ci-tests-2\/#primaryimage\"},\"thumbnailUrl\":\"http:\/\/www.isacaguiar.com.br\/blog\/wp-content\/uploads\/2026\/03\/ChatGPT-Image-Mar-24-2026-11_41_56-PM-1.png\",\"datePublished\":\"2026-03-25T02:44:59+00:00\",\"dateModified\":\"2026-03-25T02:58:44+00:00\",\"author\":{\"@id\":\"http:\/\/www.isacaguiar.com.br\/blog\/#\/schema\/person\/78719359439f068d8b1e5e0bcb9d934d\"},\"description\":\"Learn how to set up CI with GitHub Actions for Java projects using Maven to run automated unit tests with a step-by-step guide.\",\"breadcrumb\":{\"@id\":\"http:\/\/www.isacaguiar.com.br\/blog\/en\/github-actions-java-maven-ci-tests-2\/#breadcrumb\"},\"inLanguage\":\"pt-BR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/www.isacaguiar.com.br\/blog\/en\/github-actions-java-maven-ci-tests-2\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-BR\",\"@id\":\"http:\/\/www.isacaguiar.com.br\/blog\/en\/github-actions-java-maven-ci-tests-2\/#primaryimage\",\"url\":\"http:\/\/www.isacaguiar.com.br\/blog\/wp-content\/uploads\/2026\/03\/ChatGPT-Image-Mar-24-2026-11_41_56-PM-1.png\",\"contentUrl\":\"http:\/\/www.isacaguiar.com.br\/blog\/wp-content\/uploads\/2026\/03\/ChatGPT-Image-Mar-24-2026-11_41_56-PM-1.png\",\"width\":1536,\"height\":1024,\"caption\":\"GitHub Actions Java Maven unit tests\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/www.isacaguiar.com.br\/blog\/en\/github-actions-java-maven-ci-tests-2\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"In\u00edcio\",\"item\":\"http:\/\/www.isacaguiar.com.br\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"CI with GitHub Actions for Java: Running Unit Tests with Maven Step by Step\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/www.isacaguiar.com.br\/blog\/#website\",\"url\":\"http:\/\/www.isacaguiar.com.br\/blog\/\",\"name\":\"Blog do Aguiar\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/www.isacaguiar.com.br\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"pt-BR\"},{\"@type\":\"Person\",\"@id\":\"http:\/\/www.isacaguiar.com.br\/blog\/#\/schema\/person\/78719359439f068d8b1e5e0bcb9d934d\",\"name\":\"isacaguiar\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-BR\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/e22bb054d1154f07e6c91b82f0d68a219b6b04b58e5e3692c30cf457b51a9e9f?s=96&d=mm&r=g\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/e22bb054d1154f07e6c91b82f0d68a219b6b04b58e5e3692c30cf457b51a9e9f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/e22bb054d1154f07e6c91b82f0d68a219b6b04b58e5e3692c30cf457b51a9e9f?s=96&d=mm&r=g\",\"caption\":\"isacaguiar\"},\"url\":\"http:\/\/www.isacaguiar.com.br\/blog\/author\/isacaguiar\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"CI with GitHub Actions for Java: Running Unit Tests with Maven Step by Step","description":"Learn how to set up CI with GitHub Actions for Java projects using Maven to run automated unit tests with a step-by-step guide.","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":"http:\/\/www.isacaguiar.com.br\/blog\/en\/github-actions-java-maven-ci-tests-2\/","og_locale":"pt_BR","og_type":"article","og_title":"CI with GitHub Actions for Java: Running Unit Tests with Maven Step by Step","og_description":"Learn how to set up CI with GitHub Actions for Java projects using Maven to run automated unit tests with a step-by-step guide.","og_url":"http:\/\/www.isacaguiar.com.br\/blog\/en\/github-actions-java-maven-ci-tests-2\/","og_site_name":"Blog do Aguiar","article_publisher":"https:\/\/www.facebook.com\/isac.velozo.aguiar","article_published_time":"2026-03-25T02:44:59+00:00","article_modified_time":"2026-03-25T02:58:44+00:00","og_image":[{"width":1024,"height":683,"url":"http:\/\/www.isacaguiar.com.br\/blog\/wp-content\/uploads\/2026\/03\/ChatGPT-Image-Mar-24-2026-11_41_56-PM-1-1024x683.png","type":"image\/png"}],"author":"isacaguiar","twitter_card":"summary_large_image","twitter_misc":{"Escrito por":"isacaguiar","Est. tempo de leitura":"3 minutos"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"http:\/\/www.isacaguiar.com.br\/blog\/en\/github-actions-java-maven-ci-tests-2\/#article","isPartOf":{"@id":"http:\/\/www.isacaguiar.com.br\/blog\/en\/github-actions-java-maven-ci-tests-2\/"},"author":{"name":"isacaguiar","@id":"http:\/\/www.isacaguiar.com.br\/blog\/#\/schema\/person\/78719359439f068d8b1e5e0bcb9d934d"},"headline":"CI with GitHub Actions for Java: Running Unit Tests with Maven Step by Step","datePublished":"2026-03-25T02:44:59+00:00","dateModified":"2026-03-25T02:58:44+00:00","mainEntityOfPage":{"@id":"http:\/\/www.isacaguiar.com.br\/blog\/en\/github-actions-java-maven-ci-tests-2\/"},"wordCount":361,"image":{"@id":"http:\/\/www.isacaguiar.com.br\/blog\/en\/github-actions-java-maven-ci-tests-2\/#primaryimage"},"thumbnailUrl":"http:\/\/www.isacaguiar.com.br\/blog\/wp-content\/uploads\/2026\/03\/ChatGPT-Image-Mar-24-2026-11_41_56-PM-1.png","articleSection":["Technology"],"inLanguage":"pt-BR"},{"@type":"WebPage","@id":"http:\/\/www.isacaguiar.com.br\/blog\/en\/github-actions-java-maven-ci-tests-2\/","url":"http:\/\/www.isacaguiar.com.br\/blog\/en\/github-actions-java-maven-ci-tests-2\/","name":"CI with GitHub Actions for Java: Running Unit Tests with Maven Step by Step","isPartOf":{"@id":"http:\/\/www.isacaguiar.com.br\/blog\/#website"},"primaryImageOfPage":{"@id":"http:\/\/www.isacaguiar.com.br\/blog\/en\/github-actions-java-maven-ci-tests-2\/#primaryimage"},"image":{"@id":"http:\/\/www.isacaguiar.com.br\/blog\/en\/github-actions-java-maven-ci-tests-2\/#primaryimage"},"thumbnailUrl":"http:\/\/www.isacaguiar.com.br\/blog\/wp-content\/uploads\/2026\/03\/ChatGPT-Image-Mar-24-2026-11_41_56-PM-1.png","datePublished":"2026-03-25T02:44:59+00:00","dateModified":"2026-03-25T02:58:44+00:00","author":{"@id":"http:\/\/www.isacaguiar.com.br\/blog\/#\/schema\/person\/78719359439f068d8b1e5e0bcb9d934d"},"description":"Learn how to set up CI with GitHub Actions for Java projects using Maven to run automated unit tests with a step-by-step guide.","breadcrumb":{"@id":"http:\/\/www.isacaguiar.com.br\/blog\/en\/github-actions-java-maven-ci-tests-2\/#breadcrumb"},"inLanguage":"pt-BR","potentialAction":[{"@type":"ReadAction","target":["http:\/\/www.isacaguiar.com.br\/blog\/en\/github-actions-java-maven-ci-tests-2\/"]}]},{"@type":"ImageObject","inLanguage":"pt-BR","@id":"http:\/\/www.isacaguiar.com.br\/blog\/en\/github-actions-java-maven-ci-tests-2\/#primaryimage","url":"http:\/\/www.isacaguiar.com.br\/blog\/wp-content\/uploads\/2026\/03\/ChatGPT-Image-Mar-24-2026-11_41_56-PM-1.png","contentUrl":"http:\/\/www.isacaguiar.com.br\/blog\/wp-content\/uploads\/2026\/03\/ChatGPT-Image-Mar-24-2026-11_41_56-PM-1.png","width":1536,"height":1024,"caption":"GitHub Actions Java Maven unit tests"},{"@type":"BreadcrumbList","@id":"http:\/\/www.isacaguiar.com.br\/blog\/en\/github-actions-java-maven-ci-tests-2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"In\u00edcio","item":"http:\/\/www.isacaguiar.com.br\/blog\/"},{"@type":"ListItem","position":2,"name":"CI with GitHub Actions for Java: Running Unit Tests with Maven Step by Step"}]},{"@type":"WebSite","@id":"http:\/\/www.isacaguiar.com.br\/blog\/#website","url":"http:\/\/www.isacaguiar.com.br\/blog\/","name":"Blog do Aguiar","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/www.isacaguiar.com.br\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"pt-BR"},{"@type":"Person","@id":"http:\/\/www.isacaguiar.com.br\/blog\/#\/schema\/person\/78719359439f068d8b1e5e0bcb9d934d","name":"isacaguiar","image":{"@type":"ImageObject","inLanguage":"pt-BR","@id":"https:\/\/secure.gravatar.com\/avatar\/e22bb054d1154f07e6c91b82f0d68a219b6b04b58e5e3692c30cf457b51a9e9f?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/e22bb054d1154f07e6c91b82f0d68a219b6b04b58e5e3692c30cf457b51a9e9f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/e22bb054d1154f07e6c91b82f0d68a219b6b04b58e5e3692c30cf457b51a9e9f?s=96&d=mm&r=g","caption":"isacaguiar"},"url":"http:\/\/www.isacaguiar.com.br\/blog\/author\/isacaguiar\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"http:\/\/www.isacaguiar.com.br\/blog\/wp-json\/wp\/v2\/posts\/1048","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.isacaguiar.com.br\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.isacaguiar.com.br\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.isacaguiar.com.br\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.isacaguiar.com.br\/blog\/wp-json\/wp\/v2\/comments?post=1048"}],"version-history":[{"count":3,"href":"http:\/\/www.isacaguiar.com.br\/blog\/wp-json\/wp\/v2\/posts\/1048\/revisions"}],"predecessor-version":[{"id":1062,"href":"http:\/\/www.isacaguiar.com.br\/blog\/wp-json\/wp\/v2\/posts\/1048\/revisions\/1062"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.isacaguiar.com.br\/blog\/wp-json\/wp\/v2\/media\/1052"}],"wp:attachment":[{"href":"http:\/\/www.isacaguiar.com.br\/blog\/wp-json\/wp\/v2\/media?parent=1048"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.isacaguiar.com.br\/blog\/wp-json\/wp\/v2\/categories?post=1048"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.isacaguiar.com.br\/blog\/wp-json\/wp\/v2\/tags?post=1048"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}