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

junitparams.internal.ParametrizedDescription Maven / Gradle / Ivy

There is a newer version: 1.1.1
Show newest version
package junitparams.internal;

import junitparams.naming.TestCaseNamingStrategy;
import org.junit.runner.Description;

class ParametrizedDescription {

    private TestCaseNamingStrategy namingStrategy;
    private String testClassName;
    private String methodName;

    ParametrizedDescription(TestCaseNamingStrategy namingStrategy, String testClassName, String methodName) {
        this.namingStrategy = namingStrategy;
        this.testClassName = testClassName;
        this.methodName = methodName;
    }

    Description parametrizedDescription(Object[] params) {
        Description parametrised = Description.createSuiteDescription(methodName);
        for (int i = 0; i < params.length; i++) {
            Object paramSet = params[i];
            String name = namingStrategy.getTestCaseName(i, paramSet);
            String uniqueMethodId = Utils.uniqueMethodId(i, paramSet, methodName);
            parametrised.addChild(
                    Description.createTestDescription(testClassName, name, uniqueMethodId)
            );
        }
        return parametrised;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy