生成ExtentReport时找不到文件异常

时间:2018-09-29 08:19:28

标签: selenium-webdriver extentreports

我无法生成版本3.1.3的ExtentReport。我的代码是:

using AventStack.ExtentReports;
using AventStack.ExtentReports.Reporter;
using NUnit.Framework;
using NUnit.Framework.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenQA.Selenium;

namespace AutomationReports
{
    class ReportsGenerationClass
    {
    protected ExtentReports _extent;
    protected ExtentTest _test;
    protected IWebDriver _driver;

    [OneTimeSetUp]
    protected void Setup()
    {
        var dir = TestContext.CurrentContext.TestDirectory + "\\";
        var fileName = this.GetType().ToString() + ".html";
        var htmlReporter = new ExtentHtmlReporter(dir + fileName);

        _extent = new ExtentReports();
        _extent.AttachReporter(htmlReporter);
    }

    [OneTimeTearDown]
    protected void TearDown()
    {
        _extent.Flush();
    }

    [SetUp]
    public void BeforeTest()
    {
        _test = _extent.CreateTest(TestContext.CurrentContext.Test.Name);
    }

    [TearDown]
    public void AfterTest()
    {
        var status = TestContext.CurrentContext.Result.Outcome.Status;
        var stacktrace = string.IsNullOrEmpty(TestContext.CurrentContext.Result.StackTrace)
                ? ""
                : string.Format("{0}", TestContext.CurrentContext.Result.StackTrace);
        Status logstatus;

        switch (status)
        {
            case TestStatus.Failed:
                logstatus = Status.Fail;
                break;
            case TestStatus.Inconclusive:
                logstatus = Status.Warning;
                break;
            case TestStatus.Skipped:
                logstatus = Status.Skip;
                break;
            default:
                logstatus = Status.Pass;
                break;
        }

        _test.Log(logstatus, "Test ended with " + logstatus + stacktrace);
        _extent.Flush();
    }


    [Test]
    public void PassingTest()
    {

        _driver.Navigate().GoToUrl("http://www.google.com");

        try
        {
            Assert.IsTrue(true);
            _test.Pass("Assertion passed");
            _test.Log(Status.Pass, "Pass");
        }
        catch (AssertionException)
        {
            _test.Fail("Assertion failed");
            _test.Log(Status.Fail, "Fail");
            throw;
        }
    }
}

我收到一个错误:

  

OneTimeSetUp:System.IO.FileNotFoundException:无法加载文件或   程序集'System.Configuration.ConfigurationManager,Version = 0.0.0.0,   文化=中性,PublicKeyToken = cc7b13ffcd2ddd51'。

系统找不到指定的文件。 我一直在寻找类似的线程,但是找不到解决方案-Unable to generate Extent report。有什么办法可以解决此错误?检查了ExtentReport dosc的示例,但仍收到相同的消息。

0 个答案:

没有答案