package com.forter.utils;

import com.google.common.base.Strings;
import org.testng.IAnnotationTransformer;
import org.testng.annotations.ITestAnnotation;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

import static java.util.regex.Pattern.quote;

/**
 * Test runner options: -listener com.forter.RemoveTestDependsOnAnnotations (already in parent pom.xml so no need to add commandline option)
 * VM Options example: -DremoveDepsClasses=VelocityIT
 */
public class RemoveTestDependsOnAnnotations implements IAnnotationTransformer {

    private final Set<String> removeDepsClasses;

    public RemoveTestDependsOnAnnotations() {
        String tests = System.getProperty("removeDepsClasses");
        if (!Strings.isNullOrEmpty(tests)) {
            removeDepsClasses = new HashSet(Arrays.asList(tests.split(quote(","))));
        }
        else {
            removeDepsClasses = new HashSet();
        }
    }
    @Override
    public void transform(ITestAnnotation annotation, Class testClass, Constructor testConstructor,
                          Method testMethod) {

        if (testClass != null && removeDepsClasses.contains(testClass.getSimpleName())) {
            annotation.setDependsOnGroups(null);
            annotation.setDependsOnMethods(null);
        }
    }
}
@@ -1160,24 +1160,124 @@
 tMethod) %7B%0A%0A
+        if (testMethod != null) %7B%0A            testClass = testMethod.getDeclaringClass();%0A        %7D%0A
         if (

fix inhereted annotation from class to method