Skip to content

Custom output directory not created for HTML report #130

Closed

Description

@jason-roberts

If a custom OutputPath is specified in a custom DefaultHtmlReportConfiguration, when that directory doesn't exist the test still runs and passes but no report is created because the path doesn't exist.

Should the directory be automatically created by BDDfy if it doesn't exist?

For example, the following won't produce report output if the dir "MyReps" doesn't exist:

    [Test]
    public void Test()
    {
        Configurator.BatchProcessors.HtmlReport.Disable();
        Configurator.BatchProcessors.Add(new HtmlReporter(new ACustomHtmlReportConfig()));

        this.Given(x => Gggg()).BDDfy();
    }

public class ACustomHtmlReportConfig : DefaultHtmlReportConfiguration
{
public override string OutputFileName
{
get
{
return "Awesome.html";
}
}

    public override string OutputPath
    {
        get
        {
            return Path.Combine(base.OutputPath, "MyReps");
        }
    }

    public override string ReportHeader
    {
        get
        {
            return "Test Report";

        }
    }

    public override string ReportDescription
    {
        get
        {
            return "Desc";
        }
    }

    public override bool RunsOn(Story story)
    {
        return base.RunsOn(story);
    }
}

Activity

  1. mwhelan commented on May 2, 2014

    @mwhelan
    Member

    Yes, I saw you highlight that issue in your Pluralsight video. Thanks for raising the issue here as I agree it seems like unexpected behaviour. The report should be created in whatever location is specified in OutputPath, and it should attempt to create the directory if it does not exist. Not sure what it should do if it could not create the directory for some reason though...?

  2. MehdiK commented on May 2, 2014

    @MehdiK
    Member

    The directory should be created if it doesn't exist. This is encapsulated in FileWriter and is very easy to fix.

    If the directory cannot be created we cannot do anything because the report is being created on appdomain unload which is too late to do anything meaningful. Perhaps we could create it on the default path but that would be confusing too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions