无法生成硒C#测试的范围报告

时间:2019-05-12 19:41:02

标签: c# selenium-webdriver visual-studio-code extentreports

我正在尝试在Visual Studio代码(1.31.1)中为Selenium Webdriver测试C#生成范围报告,但是在测试运行正常时不会生成报告。以下是测试代码。有人可以帮我生成报告吗?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenQA.Selenium;
using SeleniumExtras.PageObjects;
using OpenQA.Selenium.Support.UI;
using NUnit.Framework;
using NUnit.Framework.Interfaces;
using OpenQA.Selenium.Chrome;
using System.IO;
using NAS.PageObj;
using System.Data;
using System.Configuration;
using AventStack.ExtentReports;
using AventStack.ExtentReports.Reporter;
using AventStack.ExtentReports.Reporter.Configuration;

namespace NAS    {
     [TestFixture]       
    public class  ReportTest : BasePage
    {
        protected ExtentReports _ext ;
        protected ExtentTest _test;
        public ReportTest(IWebDriver driver) : base(driver) {
        }
          public ReportTest() {}

        [OneTimeSetUp]
         public void LoginToEOC() {
            string reportPath = "//Users//admin//NAS//test.html";
            var load = new ExtentHtmlReporter(reportPath);
            _ext = new ExtentReports();
            load.LoadConfig("//Users//admin//NAS//extent-config.xml");
            _ext.AttachReporter(load);

        }

        [Test]
        [Description("No VRM Search Defaut Time Period")]
        //[Ignore("noo")]
        public void NASSEARCH01_3() {                
            _test = _ext.CreateTest("NASSEARCH01_3"); 
            String test = "report";
            Assert.IsFalse(test.Length.Equals(2));
        }                      
        [OneTimeTearDown]
        public void tearDown(){   
         var status = TestContext.CurrentContext.Result.Outcome.Status;
            var stackTrace = "<pre>"+TestContext.CurrentContext.Result.StackTrace+"</pre>";
            var errorMessage = TestContext.CurrentContext.Result.Message;

            if (status == NUnit.Framework.Interfaces.TestStatus.Failed)
            {
                _test.Log(Status.Fail, stackTrace + errorMessage);
            }
            _ext.RemoveTest(_test);
             _ext.Flush();
        }
    }
}

测试输出:

NUnit适配器3.13.0.0:测试执行开始 在/Users/admin/NAS/bin/Debug/netcoreapp2.2/NAS.dll中运行选定的测试    NUnit3TestExecutor转换了1个NUnit测试用例之一 NUnit适配器3.13.0.0:测试执行完成 -----测试执行摘要-----

NAS.ReportTest.NASSEARCH01_3:     结果:通过

总测试次数:1.通过:1.失败:0。跳过:0

0 个答案:

没有答案