Package org.jbehave.mojo

Source Code of org.jbehave.mojo.BehaviourRunnerMojo

package org.jbehave.mojo;

import java.net.MalformedURLException;

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.jbehave.core.BehaviourRunner;
import org.jbehave.core.behaviour.Behaviours;

/**
* Mojo to run Behaviours
*
* @author Mauro Talevi
* @goal run-behaviours
*/
public class BehaviourRunnerMojo  extends AbstractJBehaveMojo {
   
    /**
     * @parameter
     * @required true
     */
    String behavioursClassName;
   
    private BehaviourRunner runner = new BehaviourRunner(System.out);
   
    public void execute() throws MojoExecutionException, MojoFailureException {
        try {
            getLog().debug("Running behaviours "+ behavioursClassName);
            Behaviours behaviours = loadBehaviours(behavioursClassName);
            Class[] classes = behaviours.getBehaviours();
            for (int i = 0; i < classes.length; i++) {
                runner.verifyBehaviour(classes[i]);
            }           
        } catch (Exception e) {
            throw new MojoExecutionException("Failed to verify behaviours", e);
        }
    }

    private Behaviours loadBehaviours(String name) throws MalformedURLException, InstantiationException, IllegalAccessException {       
        BehavioursClassLoader cl = new BehavioursClassLoader(classpathElements);
        return cl.newBehaviours(name);
    }

}
TOP

Related Classes of org.jbehave.mojo.BehaviourRunnerMojo

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.