Hi Mauro,

It works as you say. Thanks a lot!

However I found this plugin to provide better information in the JUnit window:
https://github.com/codecentric/jbehave-junit-runner


De: Mauro Talevi [mailto:mauro.tal...@aquilonia.org]
Enviado el: domingo, 18 de mayo de 2014 20:12
Para: dev@jbehave.codehaus.org
Asunto: Re: [jbehave-dev] RE: Assertion fails not captured by JUnit in Eclipse?

In the embedder controls you've configured to ignore failures. Set:

doIgnoreFailureInStories(false)


On 18 May 2014, at 17:45, Ramiro Oliva Navas 
<ramiro.ol...@aytos.es<mailto:ramiro.ol...@aytos.es>> wrote:
Source code:

MySteps.java

package com.ramirooliva.steps;

import java.util.ArrayList;

import org.jbehave.core.annotations.Given;
import org.jbehave.core.annotations.Named;
import org.jbehave.core.annotations.Then;
import org.jbehave.core.annotations.When;
import org.junit.Assert;

public class MySteps {

                ArrayList<String> miLista;

                @Given("Una lista de nombres")
                public void dadaUnaListaDeNombres() {
                               miLista = new ArrayList<String>();
                }

                @Given("La lista contiene solo Aytos")
                public void laListaContieneAytos() {
                               miLista.add("Aytos");
                               Assert.assertTrue("El array no tiene 1 nombre", 
miLista.size() == 1);
                }

                @When("Se agrega un nombre")
                public void implementStep() {
                               miLista.add("Soluciones");
                               miLista.add("Soluciones");
                }

                @Then("Deben haber $cuenta nombres")
                public void happyStep(@Named("cuenta") int cuenta) {
                               Assert.assertTrue("El array NO tiene " + cuenta 
+ " nombres", miLista.size() == cuenta);
                }

}


my.story:

Scenario: A scenario with some pending steps

Given Una lista de nombres
And La lista contiene solo Aytos
When Se agrega un nombre
Then Deben haber 2 nombres


MyStories.java

package com.ramirooliva;

import static org.jbehave.core.io.CodeLocations.codeLocationFromClass;
import static org.jbehave.core.reporters.Format.CONSOLE;
import static org.jbehave.core.reporters.Format.HTML;
import static org.jbehave.core.reporters.Format.TXT;
import static org.jbehave.core.reporters.Format.XML;

import java.text.SimpleDateFormat;
import java.util.List;

import org.jbehave.core.Embeddable;
import org.jbehave.core.configuration.Configuration;
import org.jbehave.core.configuration.MostUsefulConfiguration;
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.RegexStoryParser;
import org.jbehave.core.reporters.StoryReporterBuilder;
import org.jbehave.core.steps.InjectableStepsFactory;
import org.jbehave.core.steps.InstanceStepsFactory;
import org.jbehave.core.steps.ParameterConverters;
import org.jbehave.core.steps.ParameterConverters.DateConverter;
import org.jbehave.core.steps.ParameterConverters.ExamplesTableConverter;
import org.junit.Test;

import com.ramirooliva.steps.MySteps;

/**
* <p>
* {@link Embeddable} class to run multiple textual stories via JUnit.
* </p>
* <p>
* Stories are specified in classpath and correspondingly the {@link 
LoadFromClasspath} story loader is configured.
* </p>
 */
public class MyStories extends JUnitStories {

    public MyStories() {
        
configuredEmbedder().embedderControls().doGenerateViewAfterStories(true).doIgnoreFailureInStories(true)
                
.doIgnoreFailureInView(true).useThreads(2).useStoryTimeoutInSecs(60);
    }

    @Override
    public Configuration configuration() {
        Class<? extends Embeddable> embeddableClass = this.getClass();
        // 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.addConverters(new DateConverter(new 
SimpleDateFormat("yyyy-MM-dd")),
                new ExamplesTableConverter(examplesTableFactory));
        return new MostUsefulConfiguration()
            .useStoryLoader(new LoadFromClasspath(embeddableClass))
            .useStoryParser(new RegexStoryParser(examplesTableFactory))
            .useStoryReporterBuilder(new StoryReporterBuilder()
                
.withCodeLocation(CodeLocations.codeLocationFromClass(embeddableClass))
               .withDefaultFormats()
                .withFormats(CONSOLE, TXT, HTML, XML))
            .useParameterConverters(parameterConverters);
    }

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

    @Override
    protected List<String> storyPaths() {
        return new 
StoryFinder().findPaths(codeLocationFromClass(this.getClass()), "**/*.story", 
"**/excluded*.story");

    }

    @Test
    public void run() throws Throwable {
                super.run();
    }

}

De: Ramiro Oliva Navas [mailto:ramiro.ol...@aytos.es]
Enviado el: domingo, 18 de mayo de 2014 17:42
Para: dev@jbehave.codehaus.org<mailto:dev@jbehave.codehaus.org>
Asunto: [jbehave-dev] Assertion fails not captured by JUnit in Eclipse?

Hi !

Could any soul please tell me what I’m doing wrong?

I have a simple HelloWorld project using jBehave for which even stories run ok 
and errors are shown in the Eclipse console, no assertion failure is captured 
in the JUnit window within Eclipse IDE.

Attached snapshot:

<image001.png>

Reply via email to