TestStack / TestStack.BDDfy

BDDfy is the simplest BDD framework EVER!
MIT License
417 stars 84 forks source link

Examples not working when implemented in base class #253

Open paulmarshall opened 7 years ago

paulmarshall commented 7 years ago

I get the UnusedExampleValueException when trying to execute a test defined in a base class that includes a fluent based scenario incorporating an example.

In my setup my test fixture derives from a base class. The base class includes a test and fields. The test includes a fluent-based scenario that includes an example, and the headers of the examples match the name of the field(s) on the base class.

The test passed when there were no base classes.

impeccable-tester commented 7 years ago

Hi Paul can you post your example. Cheers.

paulmarshall commented 7 years ago

In summary, the implementation is as follows:

public abstract class MapperTests
{
    private Request request;
    private Response response;
    private string input;

    [Test]
    public void CheckResponseIsOk()
    {
        this.Given(_, => _.A_Valid_Request())
            .When(_, => _.Map_Is_Called())
            .Then(_, => _.Result_Is_Ok())
            .WithExamples(new ExampleTable("input")
            {
                {"7"}
            })
            .BDDfy();   
    }

    private void A_Valid_Request()
    {
        this.request = new Request(this.input);
    }

    private void Map_Is_Called()
    {
        var mapper = CreateMapper();
        this.response = mapper.Map(this.request);
    }

    private void Result_Is_Ok()
    {
        this.response.Field.ShouldBe(this.input);
    }
}

[TestFixture]
public class SpecificMapperTests : MapperTests
{

}