All Downloads are FREE. Search and download functionalities are using the official Maven repository.

junit5.TagHelper Maven / Gradle / Ivy

Go to download

Selenium-Toolkit is a Java based test-toolkit for selenium-testing with testNg. The goal of the toolkit is, to suport you in different things like 'how to manage testdata in the source', parallelisation, Webdriver-managemet, reporting and a lot more.

There is a newer version: 3.0.12
Show newest version
package junit5;

import org.junit.platform.engine.TestTag;
import org.junit.platform.launcher.TestIdentifier;

import java.util.Optional;

public class TagHelper {

    private static final String CAPABILITIES = "capabilities=";
    private static final String TEST_CONFIG = "testConfig=";

    public static boolean hasCapibilityTag(TestIdentifier testIdentifier){
        return testIdentifier.getTags().stream().anyMatch(testTag -> testTag.toString().startsWith(CAPABILITIES));
    }

    public static String[] getCapibilityTag(TestIdentifier testIdentifier){
        String[] result = new String[0];
        Optional optionalTestTag = testIdentifier.getTags().stream().filter(testTag -> testTag.toString().startsWith(CAPABILITIES)).findFirst();
        if(optionalTestTag.isPresent()){
            result = optionalTestTag.toString().substring(CAPABILITIES.length()).split(",");
        }
        return result;
    }

    public static boolean hasTestConfigTag(TestIdentifier testIdentifier){
        return testIdentifier.getTags().stream().anyMatch(testTag -> testTag.toString().startsWith(TEST_CONFIG));
    }

    public static String[] getTestConfigTag(TestIdentifier testIdentifier){
        String result[] = new String[0];
        Optional optionalTestTag = testIdentifier.getTags().stream().filter(testTag -> testTag.toString().startsWith(CAPABILITIES)).findFirst();
        if(optionalTestTag.isPresent()){
            result = optionalTestTag.get().toString().substring(TEST_CONFIG.length()).split(",");
        }
        return result;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy