我是NUnit的新手,并且与SpecFlow测试框架和NUnit测试框架相混淆.
现有项目使用NUnit,如下所示.具有[Test]属性的所有方法都显示在NUnit GUI中(如果从方法中删除[Test],则测试用例不会显示在NUnit GUI中):
[TestFixture]
public class AccountTest
{
[Test]
public void TransferFunds()
{
Account source = new Account();
source.Deposit(200m);
}
[Test]
public void TransferWithInsufficientFunds()
{
}
}
Run Code Online (Sandbox Code Playgroud)
当我在同一个项目中使用SpecFlow进行编码时,SpecFlow框架是不同的,从[Given],[When],[Then]开始.每个SpecFlow场景都显示在Nunit GUI上.
我正在做的是用一个SpecFlow方法替换每个[Test]方法.例如:
[Test]
public void TransferFunds()
{
Account source = new Account();
source.Deposit(200m);
}
Run Code Online (Sandbox Code Playgroud)
转向
[Then(@"I Transfer Funds")]
public void ITransferFunds()
{
Account source = new Account();
source.Deposit(200m);
}
Run Code Online (Sandbox Code Playgroud)
这是我的问题:
看起来SpecFlow无法识别NUnit属性[Test]或[Setup].要使用SpecFlow完成项目,我是否需要摆脱所有NUnit框架并替换为SpecFlow的框架?
我可以看到有很多文章在讨论"SpecFlow + NUnit",但它们要么是SpecFlow [Given],[When],[Then]还是NUnit [Test],[TestCase].如何在一个项目中工作或者我对NUnit的理解是完全错误的?
我的问题可能是非常入门级的,谢谢你的答案!