【发布时间】:2026-01-03 16:05:02
【问题描述】:
试图让我的单元测试运行,但在单击“运行测试”后,我的输出中只得到“NUnit3TestExecutor 转换了 1 个 NUnit 测试用例”。测试尝试运行,但最终永远加载,直到我不得不手动取消该过程。知道是什么原因造成的吗?
using NUnit.Framework;
using CalculatorApp;
using System.IO;
using System;
using NUnit;
namespace Tests
{
public class Tests
{
[SetUp]
public void Setup()
{
}
[Test]
public void Test1()
{
using (StringWriter sw = new StringWriter())
{
Console.SetOut(sw);
CalculatorApp.Program.Input1();
string expected = string.Format("Type a number, and then press Enter", Environment.NewLine);
Assert.AreEqual(expected, sw.ToString());
sw.Close();
}
}
}
}
【问题讨论】:
标签: unit-testing nunit console-application nunit-3.0