简体   繁体   English

Nunit 3 和 Selenium C# 的报告工具

[英]Reporting tool for Nunit 3 and Selenium C#

I'm using Selenium with C# to create my automated tests.我在 C# 中使用 Selenium 来创建我的自动化测试。 Now i have to use some sort of reporting tools to save the test cases whether they passed,failed...etc.现在我必须使用某种报告工具来保存测试用例是否通过,失败......等。

I've seen a lot of tools like Allure, and Jenkins.我见过很多工具,比如 Allure 和 Jenkins。 But they require an XML file.但它们需要一个 XML 文件。 and i can't find it when i run my tests using Visual 2013. Why is that ?我在使用 Visual 2013 运行测试时找不到它。这是为什么?

how to obtain these XML files in details if i'm missing something ?如果我遗漏了什么,如何详细获取这些 XML 文件

Is there any way i could achieve this with minimum effort ?有什么办法可以以最少的努力实现这一目标吗?

EDIT: How can i run my tests using Nunit console runner ?编辑:如何使用 Nunit 控制台运行程序运行我的测试? where can i find it?我在哪里可以找到它? i downloaded the .zip for nunit but i couldn't find the runner?我下载了 nunit 的 .zip,但我找不到跑步者?

The NUnit Visual Studio Adapter does not currently produce XML results, although there is an issue on GitHub to add the ability. NUnit Visual Studio Adapter 当前不生成 XML 结果,尽管GitHub上存在添加此功能的问题。 Your best bet is to run your tests using the NUnit Console runner when you want to create reports.当您想要创建报告时,最好的办法是使用 NUnit 控制台运行程序运行您的测试。 It always produces an XML result file.它始终生成一个 XML 结果文件。

You can install the NUnit Console by adding the NUnit.Console NuGet package to your test project.您可以通过将NUnit.Console NuGet 包添加到您的测试项目来安装 NUnit 控制台。 The console will be in a directory like packages\\NUnit.ConsoleRunner.3.4.0\\tools in your solution root.控制台将在您的解决方案根目录中的一个目录中,如packages\\NUnit.ConsoleRunner.3.4.0\\tools

Another option is to install the MSI for the console runner .另一种选择是为控制台运行程序安装MSI It will then be under C:\\Program Files (x86)\\NUnit.org\\nunit-console然后它将在C:\\Program Files (x86)\\NUnit.org\\nunit-console

For creating reports, ReportUnit creates excellent HTML reports from your test results.为了创建报告, ReportUnit根据您的测试结果创建出色的 HTML 报告。

To run the tests, I would recommend setting up a simple command line build that builds your solution, runs the tests and then produces the report.要运行测试,我建议设置一个简单的命令行构建来构建您的解决方案、运行测试然后生成报告。 For day to day development, just running your tests in Visual Studio or on the command line will likely be enough.对于日常开发,只需在 Visual Studio 或命令行中运行测试就足够了。 Most developers find the Visual Studio Test Explorer Window to be a poor UI, but usable for seeing passed and failed tests and running/debugging them.大多数开发人员发现 Visual Studio 测试资源管理器窗口是一个糟糕的 UI,但可用于查看通过和失败的测试以及运行/调试它们。

If you want to setup a command line build, one good tool is Cake Build .如果你想设置一个命令行构建,一个很好的工具是Cake Build It will take a bit of time to setup, but it is an excellent way to run your build tasks as your project gets larger.设置需要一些时间,但随着项目变大,这是运行构建任务的绝佳方式。

NUnit testing can be run with the nunit-console.exe application which is installed with nunit under {Project_root}/lib/nunit/nunit-console.exe. NUnit 测试可以使用 nunit-console.exe 应用程序运行,该应用程序与 nunit 一起安装在 {Project_root}/lib/nunit/nunit-console.exe 下。 It downloads with NuGet when NUnit installs.当 NUnit 安装时,它会随 NuGet 一起下载。

It can be passed a list of testing binaries, or testing project files, or an nunit project (listing multiple if needed).它可以传递测试二进制文件列表、测试项目文件或 nunit 项目(如果需要,可以列出多个)。

{PathToProject}\lib\nunit\nunit-console.exe {PathToTestDll}\Project1.Tests.dll {PathToTestDll}\Project2.Tests.dll /xml=nunit-result.xml

or create an NUnit Project with the NUnit Project Editor if you want to group all your test projects into a single config file.或者,如果要将所有测试项目组合到一个配置文件中,请使用NUnit 项目编辑器创建一个 NUnit 项目。

{PathToProject}\lib\nunit\nunit-console.exe {PathToNUnitProject}\Project.Tests.nunit /xml=nunit-result.xml

Allure doesn't require xml.引诱不需要 xml。 At lease now :)至少现在:)

https://github.com/unickq/allure-nunit https://github.com/unickq/allure-nunit

You just use [AllureNUnit] attribure你只需使用 [AllureNUnit] 属性

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM