NUnit - 设置、测试和拆卸 - 未调用
NUnit - SetUp, Test and TearDown - Not invoked
我正在尝试通过 C# 执行 Selenium webdriver 测试自动化。我想基本了解 NUnit 的工作原理。我在 VS
中有以下代码
namespace SeleniumCHash
{
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using System;
using NUnit.Framework;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
[TestFixture]
public class StartUpClassCopy
{
[SetUp]
public void Initialize() {
Console.WriteLine("hi");
}
[Test]
public void LoginCheckCopy()
{
Console.WriteLine("hiTest");
}
[TearDown]
public void EndTest()
{
Console.WriteLine("hiTear");
}
}
}
当我通过测试资源管理器执行此操作时,输出如下。
[12/4/2018 7:12:46 AM Informational] ------ Discover test started ------
[12/4/2018 7:12:49 AM Warning] No test is available in C:\Users\XXXX\Source\Repos\SeleniumCHash\SeleniumCHash\SeleniumCHash.csproj. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.
[12/4/2018 7:12:49 AM Informational] ========== Discover test finished: 0 found (0:00:03.4464214) ==========
[12/4/2018 7:13:04 AM Informational] ------ Run test started ------
[12/4/2018 7:13:05 AM Informational] NUnit Adapter 3.11.2.0: Test execution started
[12/4/2018 7:13:05 AM Informational] Running selected tests in C:\Users\XXXX\Source\Repos\SeleniumCHash\SeleniumCHash\bin\Debug\SeleniumCHash.exe
[12/4/2018 7:13:06 AM Informational] NUnit3TestExecutor converted 2 of 2 NUnit test cases
[12/4/2018 7:13:06 AM Informational] NUnit Adapter 3.11.2.0: Test execution complete
[12/4/2018 7:13:06 AM Informational] ========== Run test finished: 1 run (0:00:02.0547664) ==========
我实际上希望控制台在控制台中显示它。
hi
hiTest
hiTear
Visual Studio输出window不是控制台。 :-) 事实上,运行在 Test Explorer 下,没有可用的控制台。
然而,NUnit 捕获定向到控制台的输出并对其进行处理,将其保存为测试结果的一部分。 运行ner 也可以使用该结果,它也可以做自己的事情。
对于 NUnit 3 VS 适配器,它所做的是将文本输出添加到测试资源管理器中显示的测试结果。如果您 select 是 运行 的测试,它会在 IDE 中可见。在测试树下方,您将看到结果,包括文本输出。
我正在尝试通过 C# 执行 Selenium webdriver 测试自动化。我想基本了解 NUnit 的工作原理。我在 VS
中有以下代码namespace SeleniumCHash
{
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using System;
using NUnit.Framework;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
[TestFixture]
public class StartUpClassCopy
{
[SetUp]
public void Initialize() {
Console.WriteLine("hi");
}
[Test]
public void LoginCheckCopy()
{
Console.WriteLine("hiTest");
}
[TearDown]
public void EndTest()
{
Console.WriteLine("hiTear");
}
}
}
当我通过测试资源管理器执行此操作时,输出如下。
[12/4/2018 7:12:46 AM Informational] ------ Discover test started ------
[12/4/2018 7:12:49 AM Warning] No test is available in C:\Users\XXXX\Source\Repos\SeleniumCHash\SeleniumCHash\SeleniumCHash.csproj. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.
[12/4/2018 7:12:49 AM Informational] ========== Discover test finished: 0 found (0:00:03.4464214) ==========
[12/4/2018 7:13:04 AM Informational] ------ Run test started ------
[12/4/2018 7:13:05 AM Informational] NUnit Adapter 3.11.2.0: Test execution started
[12/4/2018 7:13:05 AM Informational] Running selected tests in C:\Users\XXXX\Source\Repos\SeleniumCHash\SeleniumCHash\bin\Debug\SeleniumCHash.exe
[12/4/2018 7:13:06 AM Informational] NUnit3TestExecutor converted 2 of 2 NUnit test cases
[12/4/2018 7:13:06 AM Informational] NUnit Adapter 3.11.2.0: Test execution complete
[12/4/2018 7:13:06 AM Informational] ========== Run test finished: 1 run (0:00:02.0547664) ==========
我实际上希望控制台在控制台中显示它。
hi
hiTest
hiTear
Visual Studio输出window不是控制台。 :-) 事实上,运行在 Test Explorer 下,没有可用的控制台。
然而,NUnit 捕获定向到控制台的输出并对其进行处理,将其保存为测试结果的一部分。 运行ner 也可以使用该结果,它也可以做自己的事情。
对于 NUnit 3 VS 适配器,它所做的是将文本输出添加到测试资源管理器中显示的测试结果。如果您 select 是 运行 的测试,它会在 IDE 中可见。在测试树下方,您将看到结果,包括文本输出。