JBehave Gradle JUnitstories配置构建成功,无需执行

时间:2015-04-27 01:50:27

标签: java junit gradle bdd jbehave

我正在使用JBehave进行BDD项目。

我的构建在cmd中显示成功,但没有调用测试执行。

以下是我的测试用例配置:

package com.bdd.wk;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;
//import org.apache.wicket.util.convert.converter.DateConverter;
import org.jbehave.core.Embeddable;
import org.jbehave.core.configuration.Configuration;
import org.jbehave.core.configuration.MostUsefulConfiguration;
import org.jbehave.core.embedder.Embedder;
import org.jbehave.core.i18n.LocalizedKeywords;
import org.jbehave.core.io.CodeLocations;
import org.jbehave.core.io.LoadFromClasspath;
import org.jbehave.core.io.StoryFinder;
import org.jbehave.core.junit.JUnitStories;
import org.jbehave.core.model.ExamplesTableFactory;
import org.jbehave.core.parsers.RegexPrefixCapturingPatternParser;
import org.jbehave.core.parsers.RegexStoryParser;
import org.jbehave.core.reporters.CrossReference;
import org.jbehave.core.reporters.StoryReporterBuilder;
import org.jbehave.core.reporters.StoryReporterBuilder.Format;
import org.jbehave.core.steps.InjectableStepsFactory;
import org.jbehave.core.steps.InstanceStepsFactory;
import org.jbehave.core.steps.ParameterConverters;
import org.jbehave.core.steps.ParameterConverters.ParameterConverter;
import org.junit.runner.RunWith;

import static org.jbehave.core.io.CodeLocations.*;

//import com.suj.steps.AnnotationJbehaveSteps;
//import com.bddsuj.steps.JbehaveSteps;
import com.bdd.wk.JbehaveSteps;
//import com.suj.steps.jbehaveUltimatix;

//@RunWith(JUnitReportingRunner.class)
public class JbehaveExecTest extends JUnitStories {

private final CrossReference xref = new CrossReference();

public JbehaveExecTest() {
        configuredEmbedder().embedderControls().doGenerateViewAfterStories(true).doIgnoreFailureInStories(false)
            .doIgnoreFailureInView(true).doVerboseFailures(true).useThreads(2).useStoryTimeoutInSecs(60);
    //configuredEmbedder().useEmbedderControls(new    PropertyBasedEmbedderControls());
}//configuredEmbedder().useEmbedderControls(new    PropertyBasedEmbedderControls());


@SuppressWarnings("deprecation")
@Override
public Configuration configuration() {
Class<? extends Embeddable> embeddableClass = this.getClass();
Properties viewResources = new Properties();
viewResources.put("decorateNonHtml", "true");
viewResources.put("reports", "ftl/jbehave-reports-with-totals.ftl");
// Start from default ParameterConverters instance
ParameterConverters parameterConverters = new ParameterConverters();
// factory to allow parameter conversion and loading from external resources    (used by StoryParser too)
ExamplesTableFactory examplesTableFactory = new ExamplesTableFactory(new    LocalizedKeywords(), new LoadFromClasspath(embeddableClass),   parameterConverters);
// add custom converters
//parameterConverters.defaultConverters(null,null;
 return new MostUsefulConfiguration()
.useStoryLoader(new LoadFromClasspath(embeddableClass))
.useStoryParser(new RegexStoryParser(examplesTableFactory)) 
.useStoryReporterBuilder(new StoryReporterBuilder()
    .withCodeLocation(CodeLocations.codeLocationFromClass(embeddableClass))
         //.withCodeLocation(CodeLocations.codeLocationFromPath("target/classes")) 
    //.withDefaultFormats()
    .withViewResources(viewResources)
    .withFormats(Format.CONSOLE, Format.TXT, Format.STATS)
    .withFailureTrace(true)
    .withFailureTraceCompression(true)                
    .withCrossReference(xref)) 
.useParameterConverters(parameterConverters)                     
.useStepMonitor(xref.getStepMonitor());                               
}

@Override
public InjectableStepsFactory stepsFactory() {
return new InstanceStepsFactory(configuration(), new JbehaveSteps());
}

@Override
protected List<String> storyPaths() {
   //Specify story paths as URLs
StoryFinder finder = new StoryFinder();
//return finder.findPaths(codeLocationFromClass(this.getClass()).getFile(),   Arrays.asList("**/*.story"), Arrays.asList(""));
//return finder.findPaths(codeLocationFromClass(this.getClass()).getFile(),   Arrays.asList("**/AnnotationJbehaveFeature.story"), Arrays.asList(""));
return finder.findPaths(codeLocationFromClass(this.getClass()).getFile(),   Arrays.asList("**/JbehaveFeature.story"), Arrays.asList(""));
}
}`

下面是我的gradle构建文件:

apply plugin: 'java'
apply plugin: 'maven'

group = 'com.bdd.wk' 

repositories {
    mavenCentral()
}

dependencies {
compile group: 'org.seleniumhq.selenium', name: 'selenium-java',      version:'2.44.0'
compile group: 'org.seleniumhq.selenium', name: 'selenium-chrome-driver', version:'2.44.0'
compile group: 'org.apache.poi', name: 'poi', version:'3.11'
compile group: 'com.googlecode.json-simple', name: 'json-simple', version:'1.1.1'
compile group: 'org.jbehave', name: 'jbehave-core', version:'3.9.5'
compile group: 'org.jbehave.web', name: 'jbehave-web-selenium', version:'3.5.5'
compile group: 'org.jbehave.site', name: 'jbehave-site-resources', version:'3.2'
compile group: 'ch.qos.logback', name: 'logback-classic', version:'1.1.2'


testCompile (
        [group: 'junit', name: 'junit', version: '4.11'],
        [group: 'de.codecentric', name: 'jbehave-junit-runner', version:  '1.1.2'],
        [group: 'info.cukes', name:'cucumber-junit', version: '1.2.2']
        )
 }

task wrapper(type: Wrapper) {
gradleVersion = '2.3'
}

为什么在执行cmd命令&#34; gradle build&#34;之后我的测试没有执行。在gradle构建文件所在的项目目录中?

0 个答案:

没有答案