zoukankan      html  css  js  c++  java
  • [翻译]NUnit---RequiredAddin and RequiresMTA Attributes(十六)

    RequiredAddinAttribute (NUnit 2.5)

      RequiredAddin特性用于提示一个程序集需要特殊的插件才能保证功能正常。如果没有安装插件,整个程序集会被标记为未运行。

    Note:Alpha-3版本,这个特性可以运用于类或方法。但这是受限制的,主要有2个原因:

      1、如由于遗漏了插件,那么这个方法或者类不被认可为一个测试,NUnit一直都不会处理它。

      2、如果这个方法或者类又不同的插件处理,插件肯能无法识别这个特性

    在下个版本中这个特性可能会被限制于程序集。

    Example

    [assembly: RequiredAddin("MyTestFixtureAddin")]
    [assembly: RequiredAddin("MyTestAddin")]
    [assembly: RequiredAddin("MyDecoratorAddin")]
    
    ...
    
    namespace NUnit.Tests
    {
      using System;
      using NUnit.Framework;
    
      [MyTestFixture]
      public class MyTests
      {
        [MyTest]
        public void SomeTest()
        {
          ...
        }
      }
      
      [TestFixture, MyDecorator]
      public class MoreTests
      {
        [Test, MyDecorator]
        public void AnotherTest()
        {
          ...
        }
      }
    }

     

    RequiresMTAAttribute (NUnit 2.5)

      RequiresMTA特性可以应用与测试方法、类或者程序集,用于指定这些测试应该在多线程环境下运行。如果父类测试没有在多线程中运行那么它会创建一个新的进程。

    Note:在测试方法你也可以使用RequiresMTA特性。尽管运行时只在执行程序集入口确认,许多用户希望在测试上工作,所以我们把它当作同义词。

    Examples

    // An MTA thread will be created and used to run
    // all the tests in the assembly
    [assembly:RequiresMTA]
    
    ...
    
    // TestFixture requiring a separate thread
    [TestFixture, RequiresMTA]
    public class FixtureRequiringMTA
    {
      // An MTA thread will be created and all
      // tests in the fixture will run on it
      // unless the containing assembly is
      // already running on an MTA Thread
    }
    
    [TestFixture]
    public class AnotherFixture
    {
      [Test, RequiresMTA]
      public void TestRequiringMTA()
      {
        // A separate thread will be created for this test
        // unless the containing fixture is already running 
        // in the MTA.
      }
    }

    See also...

    • RequiresThreadAttribute
    • RequiresSTAAttribute
  • 相关阅读:
    解疑网络监控卡壳 视觉体验400ms延时
    DDD实战11 在项目中使用JWT的token 进行授权验证
    在sql语句中 inner join ,left join,right join 和on 以及where
    在.net core自带DI中服务生命周期 Transient,Scoped,Singleton
    DDD实战10 在项目中使用JWT的token
    简单使用.net core 自带的DI
    在.net core中一个简单的加密算法
    DDD实战9 经销商领域上下文
    DDD实战8_2 利用Unity依赖注入,实现接口对应实现类的可配置
    DDD实战8_1 实现对领域中连接字符串的可配置
  • 原文地址:https://www.cnblogs.com/kim01/p/3464361.html
Copyright © 2011-2022 走看看