小编mje*_*zzi的帖子

BD#for C#NUnit

我一直在使用家庭酿造的BDD Spec扩展来在NUnit中编写BDD样式测试,我想看看每个人都在想什么.它增加了价值吗?真是太糟糕了?如果是这样的话?那里有更好的东西吗?

这是源:https: //github.com/mjezzi/NSpec

我创建这个有两个原因

  1. 使我的测试易于阅读.
  2. 生成普通英语输出以查看规范.

以下是测试外观的示例:

- 这些天僵尸似乎很受欢迎..

鉴于Zombie,Peson和IWeapon:

namespace Project.Tests.PersonVsZombie
{
    public class Zombie
    {

    }

    public interface IWeapon
    {
        void UseAgainst( Zombie zombie );
    }

    public class Person
    {
        private IWeapon _weapon;

        public bool IsStillAlive { get; set; }

        public Person( IWeapon weapon )
        {
            IsStillAlive = true;
            _weapon = weapon;
        }

        public void Attack( Zombie zombie )
        {
            if( _weapon != null )
                _weapon.UseAgainst( zombie );
            else
                IsStillAlive = false;
        }
    }
} …
Run Code Online (Sandbox Code Playgroud)

c# bdd nunit

10
推荐指数
2
解决办法
9088
查看次数

标签 统计

bdd ×1

c# ×1

nunit ×1