# How to include TestNG tests without a group while including one group and excluding another group?

**URL:** https://discuss.gradle.org/t/how-to-include-testng-tests-without-a-group-while-including-one-group-and-excluding-another-group/4457
**Category:** Old Forum Archive
**Created:** [May 22, 2012, 6:58am UTC](https://discuss.gradle.org/t/how-to-include-testng-tests-without-a-group-while-including-one-group-and-excluding-another-group/4457 "2012-05-22T06:58:00Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![abegg\_ch](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@abegg\_ch](https://discuss.gradle.org/u/abegg_ch)
#### Post date: [May 22, 2012, 6:58am UTC](https://discuss.gradle.org/t/how-to-include-testng-tests-without-a-group-while-including-one-group-and-excluding-another-group/4457/1 "2012-05-22T06:58:00Z")

</div>

My projects has three kind of TestNG tests:

```gradle
@Test(groups="A") // tests in group A
 @Test(groups="B") // tests in group B
@Test // tests not assigned to a specific group

```

I’d like to configure gradle to run the tests in group A and the non-grouped tests but not the tests in group B.

I tried:

```gradle
test.options.includeGroups 'A'
test.options.excludeGroups 'B'

```

But this configuration only runs the tests in group A and not the non-grouped tests.

---

<div class="post-metadata">

### Author: ![abegg\_ch](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@abegg\_ch](https://discuss.gradle.org/u/abegg_ch)
#### Post date: [May 22, 2012, 7:15am UTC](https://discuss.gradle.org/t/how-to-include-testng-tests-without-a-group-while-including-one-group-and-excluding-another-group/4457/2 "2012-05-22T07:15:00Z")

</div>

Inspired by: [http://stackoverflow.com/questions/4511297/can-i-run-all-the-testng-tests-that-do-not-belong-to-any-group-in-maven](http://stackoverflow.com/questions/4511297/can-i-run-all-the-testng-tests-that-do-not-belong-to-any-group-in-maven)

This does not help either (runs only group A)

```gradle
test.options.includeGroups 'A'
test.options.includeGroups '.\*'
test.options.excludeGroups 'B'

```

This leads to a parsing exception:

```gradle
test.options.includeGroups 'A'
test.options.includeGroups '\*'
test.options.excludeGroups 'B'

```

---

<div class="post-metadata">

### Author: ![abegg\_ch](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@abegg\_ch](https://discuss.gradle.org/u/abegg_ch)
#### Post date: [May 22, 2012, 8:15am UTC](https://discuss.gradle.org/t/how-to-include-testng-tests-without-a-group-while-including-one-group-and-excluding-another-group/4457/3 "2012-05-22T08:15:00Z")

</div>

The following configuration is working. I do not use any includeGroups.

```gradle
test.options.excludeGroups 'B'

```
