<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/how-to-execute-tests-selectively-in-testng-ojhjznhhx" -->

---
title: How to Execute Tests Selectively in TestNG | daily.dev
description: TestNG offers multiple ways to selectively execute tests instead of re-running entire suites. You can use the auto-generated testng-failed.xml file to re-run...
canonical: https://daily.dev/posts/how-to-execute-tests-selectively-in-testng-ojhjznhhx
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: How to Execute Tests Selectively in TestNG | daily.dev
og:description: TestNG offers multiple ways to selectively execute tests instead of re-running entire suites. You can use the auto-generated testng-failed.xml file to re-run...
og:url: https://daily.dev/posts/how-to-execute-tests-selectively-in-testng-ojhjznhhx
og:image: https://api.daily.dev/og/posts/OjhJZNHHx.png
og:image:alt: How to Execute Tests Selectively in TestNG
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# How to Execute Tests Selectively in TestNG

**[Baeldung](https://daily.dev/sources/baeldung)** · 6 min read · 0 upvotes · 0 comments

## Summary

TestNG offers multiple ways to selectively execute tests instead of re-running entire suites. You can use the auto-generated testng-failed.xml file to re-run only failed tests, manually create testng.xml with specific test inclusions, execute single methods via Maven Surefire's -Dtest parameter, skip tests dynamically using @BeforeMethod with SkipException, implement IMethodInterceptor for pre-execution filtering, or run individual tests directly from your IDE. Each approach serves different scenarios, from CI pipeline automation to quick local debugging.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://feeds.feedblitz.com/~/942289685/0/baeldung~How-to-Execute-Tests-Selectively-in-TestNG>

## Similar posts on daily.dev

- [Conditionally Ignore Tests in TestNG](https://daily.dev/posts/conditionally-ignore-tests-in-testng-ymsrh8jkr) · Baeldung · 1 upvotes · 0 comments
- [CircleCI Smarter Testing: Stop running tests that don't matter](https://daily.dev/posts/circleci-smarter-testing-stop-running-tests-that-don-t-matter-colzpxw8r) · CircleCI · 0 upvotes · 0 comments
- [How I Think About Tests: Skips](https://daily.dev/posts/how-i-think-about-tests-skips-6onvhjr3q) · RUBYLAND · 0 upvotes · 0 comments
- [How to Tame Your Flaky Tests in TeamCity](https://daily.dev/posts/how-to-tame-your-flaky-tests-in-teamcity-srhpeck9w) · JetBrains · 0 upvotes · 0 comments
- [Automated regression testing: A complete introduction](https://daily.dev/posts/automated-regression-testing-a-complete-introduction-ylcecni2u) · Testim.io · 0 upvotes · 0 comments

---

Tags: [#devtools](https://daily.dev/tags/devtools), [#java](https://daily.dev/tags/java), [#maven](https://daily.dev/tags/maven), [#testing](https://daily.dev/tags/testing)

[View this post on daily.dev](https://daily.dev/posts/how-to-execute-tests-selectively-in-testng-ojhjznhhx)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"How to Execute Tests Selectively in TestNG","url":"https://daily.dev/posts/how-to-execute-tests-selectively-in-testng-ojhjznhhx","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/how-to-execute-tests-selectively-in-testng-ojhjznhhx"},"datePublished":"2026-01-26T01:30:29.185Z","dateModified":"2026-03-15T06:06:15.305Z","description":"TestNG offers multiple ways to selectively execute tests instead of re-running entire suites. You can use the auto-generated testng-failed.xml file to re-run...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/bdf334823bf91642cdc4171ac4262e8c?_a=AQAEulh","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/bdf334823bf91642cdc4171ac4262e8c?_a=AQAEulh","isAccessibleForFree":true,"articleSection":"Baeldung","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Baeldung","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/52cccfb454d946c4b7dfa5e816f9e576","url":"https://daily.dev/sources/baeldung"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/how-to-execute-tests-selectively-in-testng-ojhjznhhx","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"devtools,java,maven,testing","timeRequired":"PT6M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Baeldung","item":"https://daily.dev/sources/baeldung"},{"@type":"ListItem","position":3,"name":"How to Execute Tests Selectively in TestNG"}]}
```

