小编ted*_*ode的帖子

xUnit.net Class Fixture 需要即将运行的测试类的名称

我有一个项目,其中多个测试类共享一个基类固定装置。

正如预期的那样,fixture 的构造函数在测试类中的任何测试运行之前运行。

有没有办法让此类固定装置的构造函数知道即将运行的测试类的名称?

背景:我的项目不进行单元测试,而是使用 xUnit.net 来运行替代类型的测试。所有类和测试都将按顺序运行,因此保证一个类在另一个类尝试运行之前完全运行。

这是我希望能够执行的操作的示例:

using Xunit;
using Xunit.Abstractions;

namespace TestingProject
{
    // In my project, the classes are guaranteed to run in order, one after the other.  Tests won't randomly execute between classes.
    // This fixture is used by multiple test classes.  It handles logging test class starts and stops to the db.
    public class SharedTestingClassFixture : IDisposable
    {
        // This will run at the start of every testing class.
        public SharedTestingClassFixture()
        {
            // Need to …
Run Code Online (Sandbox Code Playgroud)

c# xunit.net

5
推荐指数
0
解决办法
960
查看次数

标签 统计

c# ×1

xunit.net ×1