- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在重构一个使用 NUnit 3.6 的测试应用程序。大多数应用程序是由非开发人员编写的,需要重构/重组。有很多使用标准的遗留助手类
Console.Out.WriteLine();
Console.Error.WriteLine();
记录错误和测试进度的方法。为使用 NUnit 做出了一些努力
TestContext.Progress.WriteLine();
TestContext.Out.WriteLine();
TestContext.Error.WriteLine();
在测试运行时提供“实时输出”的方法,但并不一致。展望 future ,我希望所有帮助程序类/方法都使用 Console.Out/Error 方法,这样它们就可以在没有 NUnit 依赖项的情况下分离,然后在每个测试的 [SetUp] 方法中重定向输出。
[SetUp]
public void BaseTestSetupMethod(){
Console.SetError(TestContext.Error);
/* Set Console.Out to TestContext.Out or TestContext.Progress */
}
TestContext.Out 和 TestContext.Progress 有什么区别?
我应该将 Console.Out 重定向到哪一个以获取一般消息,例如打印当前正在运行的测试的名称及其正在执行的操作?
我通读了 NUnit 3 的文档,包括 https://github.com/nunit/docs/wiki/TestContext页。虽然它列出了 TestContext.Out 和 TestContext.Progress 之间的区别,但它们并不是真正的描述性的,也没有示例说明为什么您会在实践中使用一个而不是另一个。
最佳答案
答案确实在链接的文档页面 ( https://github.com/nunit/docs/wiki/TestContext ) 上,但是自从提出这个问题以来已经有一段时间了,所以也许从那时起文档页面已经得到了改进。
至少现在它说:
Out
Gets a TextWriter used for sending output to the current test result.
Error
Gets a TextWriter used for sending error output intended for immediate display.
Progress
Gets a TextWriter used for sending normal (non-error) output intended for immediate display.)
这里的关键词是“立即显示”——当某些东西被发送到 Error 和 Progress 时,意图是测试运行器应该立即显示它,而发送到 Out 的文本在每个测试用例终止之前是不可见的。
这是因为 NUnit 3 将捕获 Console.Out 并且在测试用例完成之前不会输出它。在 NUnit 2 中,常规的 Console.Out 和 Error 立即可见。
关于c# - NUnit 3 中的 TestContext.Out 和 TestContext.Progress 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44118127/
我正在重构一个使用 NUnit 3.6 的测试应用程序。大多数应用程序是由非开发人员编写的,需要重构/重组。有很多使用标准的遗留助手类 Console.Out.WriteLine(); Console
这些是在 TestContext 类和 their respective definitions 中定义的(未弃用的)目录. 部署目录 获取为测试运行部署的文件的目录。此属性通常包含 TestRunD
我正在使用 MicrosoftTestTools。我有一个包含 [TestMethod] 和 [ClassInitialize] 的 A 类。 [ClassInitialize] public sta
我需要访问 TestContext.Properties之前 TestMethod所以测试可以接收到正确的环境进行测试。 我的内容test.runsettings :
我正在使用 VS2010。 TestContext.AddResultFile() 在我的单元测试期间产生不稳定的行为。有时它会将文件添加到报告中,有时则不会。在一次又一次地运行相同的基本虚拟测试后,
按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我通过使用从 .csv 文件中读取的数据来参数化我的测试用例。 csv 文件中的一列具有美国格式的简单日期值(作为常规字符串),例如 mm/dd/yyyy。然而,当数据实际被读取并填充到 TestCo
我有一个单元测试: [Test] [TestCaseSource(typeof(AllExampleEnumValues))] public void GivenSth_WhenSth_ThenSth
我有一个测试方法正在调用 2 个子测试方法。两种子方法都是由 XML 文件驱动的数据。如果我运行每个子方法,它们运行良好且成功。但是,当我运行主测试方法(两个子方法的调用者)时,它发现 TestCon
目标: 我想使用 TestContext.TestName 属性提取正在运行的测试的名称,以便我的 [TestCleanup] 函数可以在每个测试完成时自动将结果记录到我们定制的结果存储库中。 问题:
使用 Visual Studio 生成测试单元类。然后注释进去,类的初始化方法。在其中使用 testContext 参数添加您的属性。 在测试应用程序启动时,此方法确实由测试基础架构调用。 //Use
我有一个 visual studio 2008 单元测试,我收到以下运行时错误: Unable to set TestContext property for the class JMPS.Plann
我正在尝试使用 Spring TestContext 框架对我的应用程序进行集成测试。我通过扩展 AbstractTransactionalJUnit4SpringContextTests 来做到这一
我的所有单元测试类都是由 Visual Studio 2008 从包含“TestContext”属性的内置单元测试模板创建的。到目前为止,我还没有使用过测试上下文,这个领域让 Resharper 和代
是否可以从传递给 DataProvider 的方法中获取 TextContext?这就是我的意思.. @DataProvider(name= "foo") public static Object[]
我有一个扩展方法,可以使用 DataRow 从 xml 中获取数据。而不是将行写为 TestContext.DataRow["Month"].ToString() 。我写了一个带有类型转换的扩展方法:
我希望能够在我的测试代码中访问测试的持续时间。我一直在查看 NUnit 中的 TestContext 类,但是当我找到关于“FullName”的信息时,我无法弄清楚从哪里访问测试持续时间。 [Tear
我有以下代码: [TestFixture] public class LexicalTests { [Test] public void LexicalTest1() {
我有 UWP 项目。使用 VS Community 2017 我在我的解决方案中添加了一个单元测试(添加项目-> Windows Universal -> Unit Test App (Windows
我今天早上一直在玩 watiN/Nunit 以捕获失败的 UI 测试的屏幕截图。但是,我在访问 Nunits TestContext.CurrentContext 时遇到了 NRE... 关于我做错了
我是一名优秀的程序员,十分优秀!