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

org.test4j.integration.junit4.helper.FrameworkParameterMethodHelper Maven / Gradle / Ivy

package org.test4j.integration.junit4.helper;


import org.junit.runners.model.FrameworkMethod;
import org.test4j.integration.junit4.DataFrom;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * JUnit框架方法装饰
 */
public class FrameworkParameterMethodHelper {

    /**
     * 将junit测试方法转换为test4j测试方法
     *
     * @param methods
     * @return
     */
    public static List computeTestParaMethods(Class testClass, List methods) {
        List list = new ArrayList<>();
        for (FrameworkMethod method : methods) {
            List pms = FrameworkParameterMethodHelper.withParameter(testClass, method);
            list.addAll(pms);
        }
        return list;
    }

    private static List withParameter(Class testClass, FrameworkMethod method) {
        DataFrom dataFrom = method.getMethod().getAnnotation(DataFrom.class);
        if (dataFrom == null) {
            return Arrays.asList(method);
        } else {
            return DataFromHelper.computeParameterizedTestMethods(testClass, method.getMethod(), dataFrom);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy