I have a big java project using TestNG Test annotation.
I want to add parameter timeOut=100L
to all tests, that are not part of a group (defined via Test Annotation parameters). We use groups for functional/integration/etc. I want to impact only unit tests, which lack any group.
My unit tests (which are the ones I want to match) have @Test
annotation by itself, or other parameters. e.g.
@Test
public void aSimpleTest()
{
...
@Test(expectedExceptions = SomeException.class,
expectedExceptionsMessageRegExp = "my error message",
description = "Test will fail validation on X")
public void aSimpleTestWithAnotatedParameters() {
...
@Test(dataProvider = "testDataProvider")
public void aSimpleTestWithAnotatedParameters(Int InputVal) {
...
My first attempt was using IntelliJ Structural Find and Replace:
Search Template:
@$Annotation$($param1$ = $value1$,/*...*/ $paramN$ = $valueN$)
with Modifiers for both param1 and paramN: Text=!groups
replace with:
@$Annotation$(timeOut = 100L, $param1$ = $value1$,/*...*/ $paramN$ = $valueN$)
Which almost works!
The problem I can't solve is that it also matches things like:
@Test(description = "should not match this test, but it does", groups = "SlowIntegrationTest")
That is, Annotations with parameters other than group. The ones that have only group are not matched.