【问题标题】:Running BeforeTestRun/AfterTestRun once on Specflow Runner在 Specflow Runner 上运行 BeforeTestRun/AfterTestRun 一次
【发布时间】:2021-09-26 23:28:16
【问题描述】:

在使用 AppDomain 的多线程上使用 Specflow 运行器时,是否有人成功设置了 beforetestrun/aftertestrun 挂钩 我从这个帖子中看到了一些答案 - Run BeforeTestRun and AfterTestRun only once using specflow with Selenium

很遗憾,我很难设置它,因为我们需要它来配置我们的 TestRail 集成。

【问题讨论】:

    标签: specflow specrun


    【解决方案1】:

    这是可能的——你必须使用基于内核的锁(下面的构造函数是使用的): https://docs.microsoft.com/en-us/dotnet/api/system.threading.semaphore.-ctor?view=net-5.0#System_Threading_Semaphore__ctor_System_Int32_System_Int32_System_String_System_Boolean__

    流程:

    1. 创建 Semaphore 的命名实例
    2. createdNew == true 的线程是第一个进入代码的线程 - 在此处执行测试运行初始化代码
    3. 对于其他线程,请使用具有适当超时的“WaitOne”方法

    最好的问候, 下午

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-02-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多