Integration of jbehave with jenkins

。_饼干妹妹 提交于 2019-12-07 16:08:31

问题


I have to integrate jbehave with jenkins. But I don't have idea how to do this. I saw that I have to create a task in Jenkins, but I don't know where I should wire jbehave with this task.

Can somebody help me?

Thanks,

Sarang


回答1:


So I'm assuming you have JBehave integrated with Maven, correct? The simple build environment can be set up as follows:

  1. Go to Jenkins and add a new job of type "Build a maven2/3 project"
  2. Configure your project to check out your from whatever source repository you use.
  3. Configure the build phase of the project to run whatever Maven goal you need ("install" will probably work)
  4. Hit save and you have a working project that will execute exactly as it would from a command line.

If you want to see the JBehave test output rendered nicely in Jenkins you should also follow these instructions to configure the Jenkins/XUnit plugin: http://jbehave.org/reference/stable/hudson-plugin.html

You will also need to make sure your project is configured to use the XML Output format in your StoryReporterBuilder to make use of the plugin (not mentioned in the instructions above).




回答2:


You can visit the following for details:

http://jbehave.org/reference/stable/hudson-plugin.html




回答3:


Per your comments, you want to specify the stories to run via Jenkins when using the Maven plugin. Here is one way:

Create a subclass of StoryFinder and set it as the storyFinderClass property in your Maven configuration. In the Jenkins commandline launcher, you can pass in stories as a -D system property which can then be read from your StoryFinder.

Commandline

mvn ... -Dcom.sarang.stories="foo.story,bar.story"

Maven

<plugin>
    <groupId>org.jbehave</groupId>
    <artifactId>jbehave-maven-plugin</artifactId>
    <version>[version]</version>
    <executions>
        <execution>
            <id>run-stories-as-embeddables</id>
            <phase>integration-test</phase>
            <configuration>
                ...
                <systemProperties>
                    <property>
                      <name>com.sarang.stories</name>
                      <value>${com.sarang.stories}</value>
                    </property>
                </systemProperties>
                <storyFinderClass>com.sarang.MyStoryFinder</storyFinderClass>
            </configuration>
            <goals>
                <goal>run-stories-as-embeddables</goal>
                ...
            </goals>
        </execution>
    </executions>
</plugin>

StoryFinder

package com.sarang;

import org.jbehave.core.io.StoryFinder;
import java.util.*;

public class MyStoryFinder extends StoryFinder {
    @Override
    protected List<String> scan(String basedir, List<String> includes,
            List<String> excludes) {
        //List<String> defaultStories = super.scan(basedir, includes, excludes);
        String myStories = System.getProperty("com.sarang.stories");
        return Arrays.asList(myStories.split(","));
    }
}


来源:https://stackoverflow.com/questions/11972696/integration-of-jbehave-with-jenkins

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!