Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/337.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
can';t生成html文件扩展报告selenium C#_C#_Selenium_Extentreports_Selenium Extent Report - Fatal编程技术网

can';t生成html文件扩展报告selenium C#

can';t生成html文件扩展报告selenium C#,c#,selenium,extentreports,selenium-extent-report,C#,Selenium,Extentreports,Selenium Extent Report,我在visual studio C#中使用了带有selenium的ExtentReports,我运行了案例测试,但是在我在解决方案资源管理器中创建的报告文件夹中没有生成报告文件.html。我不知道问题出在哪里,我将报告文件的路径更改为“检查”,但它仍然无法生成。 这是我的密码: using NUnit.Framework; using RelevantCodes.ExtentReports; using System; using System.Collections.Generic;

我在visual studio C#中使用了带有selenium的ExtentReports,我运行了案例测试,但是在我在解决方案资源管理器中创建的报告文件夹中没有生成报告文件.html。我不知道问题出在哪里,我将报告文件的路径更改为“检查”,但它仍然无法生成。 这是我的密码:

 using NUnit.Framework;
 using RelevantCodes.ExtentReports;
 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;

namespace ExtentReportsDemo
{
[TestFixture]
public class BasicReport
{
    public ExtentReports extent;
    public ExtentTest test;

    [OneTimeSetUp]
    public void StartReport()
    {
        string pth = 
           System.Reflection.Assembly.GetCallingAssembly().CodeBase;
        string actualPath = pth.Substring(0, pth.LastIndexOf("bin"));
        Console.WriteLine("actual" + actualPath);

        string projectPath = new Uri(actualPath).LocalPath; // project path 
                                                    of your solution
        //Console.WriteLine("project" + projectPath);
        string reportPath = projectPath + "Reports\\testreport.html";
        Console.WriteLine("report" + reportPath);

        // true if you want to append data to the report.  Replace existing 
        report with new report.  False to create new report each time
        extent = new ExtentReports(reportPath, false);
        extent.AddSystemInfo("Host Name", "MININT-F36S5EH")
            .AddSystemInfo("Environment", "QA")
            .AddSystemInfo("User Name", "testUser");

        extent.LoadConfig(projectPath + "extent-config.xml");

    }

    [Test]
    public void DemoReportPass()
    {
        test = extent.StartTest("DemoReportPass");
        Assert.IsTrue(true);
        test.Log(LogStatus.Pass, "Assert Pass as consition is true");

    }

    [Test]
    public void DemoReportFail()
    {
        test = extent.StartTest("DemoReportPass");
        Assert.IsTrue(false);
        test.Log(LogStatus.Fail, "Assert Pass as condition is false");

    }

    [TearDown]
    public void GetResult()
    {
        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(LogStatus.Fail, stackTrace + errorMessage);
        }
        extent.EndTest(test);

    }

    [OneTimeTearDown]
    public void EndReport()
    {
        extent.Flush();
        extent.Close();
    }

    }

}
使用NUnit.Framework;
使用相关代码。扩展端口;
使用制度;
使用System.Collections.Generic;
使用System.Linq;
使用系统文本;
使用System.Threading.Tasks;
命名空间ExtentReportsDemo
{
[测试夹具]
公共类基本报告
{
公共延伸范围;
公共延伸试验;
[一次性设置]
公共无效StartReport()
{
字符串pth=
System.Reflection.Assembly.GetCallingAssembly().CodeBase;
字符串actualPath=pth.Substring(0,pth.LastIndexOf(“bin”);
Console.WriteLine(“实际”+实际路径);
string projectPath=新Uri(实际路径).LocalPath;//项目路径
你的解决方案
//Console.WriteLine(“项目”+项目路径);
字符串reportPath=projectPath+“Reports\\testreport.html”;
Console.WriteLine(“报告”+reportPath);
//如果要将数据附加到报表,则为true。替换现有数据
使用新报告进行报告。如果为False,则每次都创建新报告
区段=新的ExtentReports(reportPath,false);
extent.AddSystemInfo(“主机名”,“MININT-F36S5EH”)
.AddSystemInfo(“环境”、“质量保证”)
.AddSystemInfo(“用户名”、“测试用户”);
extent.LoadConfig(projectPath+“extent config.xml”);
}
[测试]
公共通行证()
{
测试=范围开始测试(“DemoReportPass”);
Assert.IsTrue(真);
test.Log(LogStatus.Pass,“Assert Pass as consistion is true”);
}
[测试]
public void DemoReportFail()
{
测试=范围开始测试(“DemoReportPass”);
Assert.IsTrue(false);
test.Log(LogStatus.Fail,“条件为false时断言通过”);
}
[撕裂]
public void GetResult()
{
var status=TestContext.CurrentContext.Result.output.status;
var stackTrace=”“+
 <?xml version="1.0" encoding="UTF-8"?>
 <extentreports>
<configuration>
<!-- report theme -->
<!-- standard, dark -->
<theme>standard</theme>

<!-- document encoding -->
<!-- defaults to UTF-8 -->
<encoding>UTF-8</encoding>

<!-- protocol for script and stylesheets -->
<!-- defaults to https -->
<protocol>https</protocol>

<!-- title of the document -->
<documentTitle>ExtentReports 2.0</documentTitle>

<!-- report name - displayed at top-nav -->
<reportName>Automation Report</reportName>

<!-- report headline - displayed at top-nav, after reportHeadline -->
<reportHeadline></reportHeadline>

<!-- global date format override -->
<!-- defaults to yyyy-MM-dd -->
<dateFormat>yyyy-MM-dd</dateFormat>

<!-- global time format override -->
<!-- defaults to HH:mm:ss -->
<timeFormat>HH:mm:ss</timeFormat>

<!-- custom javascript -->
<scripts>
  <![CDATA[
    $(document).ready(function() {

     });
    ]]>
   </scripts>

   <!-- custom styles -->
   <styles>
    <![CDATA[

  ]]>
</styles>
</configuration>
TestContext.CurrentContext.Result.StackTrace+“”; var errorMessage=TestContext.CurrentContext.Result.Message; if(status==NUnit.Framework.Interfaces.TestStatus.Failed) { 测试日志(LogStatus.Fail,stackTrace+errorMessage); } 范围.结束试验(试验); } [onetimeeartown] 公共报告() { expndure.Flush(); extent.Close(); } } }
和extent-config.xml:


标准
UTF-8
https
扩展端口2.0
自动化报告
每天
HH:mm:ss

请先按静态位置进行尝试,就像在任何驱动器C:\或D:\中一样,并检查其是否生成

如果不是,请通过更新报告终止调用来检查调试器

另外,确保您的
EndReport()
方法正在调用报告终止在其中调用的方法

如果是,尝试调用
extent.EndTest(test)EndReport()
方法中的code>,以便您可以检查它是否正在调用


若报告未要求终止,则不会生成

是的,我尝试放置静态路径,但它不起作用,我甚至考虑过调试以检查问题所在的位置,但我无法调试,因为它是一个类库,因此没有执行点。如果静态路径也不生成报告,我想这可能会导致错误属性。ExtentReports(reportPath,false);另外,我想建议您,要使用Extent Report 3如果我转到版本3,代码必须更改,ExtentReports不带参数,Extent.LoadConfig无法识别..正如我在转到版本3时所说,我必须更改代码,您是否有适合版本3的程序。我尝试了很多,但都没有成功,我所从事的项目是PerfSDK,它位于MicrosoftDynamicsAX文件夹中。