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

com.javasbar.framework.testng.dpextension.DataProviderUtils Maven / Gradle / Ivy

Go to download

DolphinNG provides set of very useful addons for testNG. Most important features that it supports are condensed smart reports, auto creation of jira ticets for test failures, linking test fails to jira tickets, progress reporting during test runs.

There is a newer version: 1.3.0
Show newest version
package com.javasbar.framework.testng.dpextension;

import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;

/**
 * @see Copied : http://www.lysergicjava.com/?p=165 and improvised
 */
public class DataProviderUtils
{
    public static Map resolveDataProviderArguments(Method testMethod) throws Exception
    {
        if (testMethod == null)
            throw new IllegalArgumentException("Test Method context cannot be null.");

        DataProviderArguments args = testMethod.getAnnotation(DataProviderArguments.class);
        if (args == null)
        {
            throw new IllegalArgumentException("Test Method context has no DataProviderArguments annotation - " + testMethod.getName());
        }
        if (args.value() == null || args.value().length == 0)
        {
            throw new IllegalArgumentException("Test Method context has a malformed DataProviderArguments annotation, testMethod: " + testMethod.getName());
        }
        Map arguments = new HashMap();
        for (int i = 0; i < args.value().length; i++)
        {
            String[] parts = args.value()[i].split("=");
            arguments.put(parts[0].trim(), parts[1]);
        }
        return arguments;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy