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

com.flextrade.jfixture.rules.FixtureRule Maven / Gradle / Ivy

Go to download

JFixture is an open source library based on the popular .NET library, AutoFixture

There is a newer version: 2.7.2
Show newest version
package com.flextrade.jfixture.rules;

import com.flextrade.jfixture.JFixture;
import com.flextrade.jfixture.runners.JUnitJFixtureStatement;
import org.junit.rules.MethodRule;
import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.Statement;

public class FixtureRule implements MethodRule {

    private final JFixture fixture;

    private FixtureRule() {
        this(new JFixture());
    }

    protected FixtureRule(JFixture fixture) {
        this.fixture = fixture;
    }

    public static FixtureRule initFixtures() {
        return new FixtureRule();
    }

    public static FixtureRule initFixtures(JFixture fixtureEngine) {
        return new FixtureRule(fixtureEngine);
    }

    @Override
    public Statement apply(final Statement base, final FrameworkMethod method, final Object target) {
      return new JUnitJFixtureStatement(base, target, fixture);
    }

    public JFixture getFixture() {
        return this.fixture;
    }

    public FixtureRuleCustomisation customise() {
        return new FixtureRuleCustomisation(fixture);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy