新手C#程序员。使用visual studio 2010中的specflow创建步骤定义文件,生成的功能文件不清晰
安装规范流程1.3,也有安装NUnit的,在我的测试项目中引用旁边,在Visual Studio 2010
从我所做的研究我的应用程序的项目,它看起来好像定义文件,添加时,可以填充针对特征文件自动生成的残段方法。
通过这个我的意思是我创建specflow功能文件使用运行单元测试,生成一个非结论性的功能文件。
当我看着这个我得到如下:
// ------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by SpecFlow (http://www.specflow.org/).
// SpecFlow Version:1.3.3.0
// Runtime Version:4.0.30319.239
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
// ------------------------------------------------------------------------------
#region Designer generated code
namespace AcceptanceTest
{
using TechTalk.SpecFlow;
[System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "1.3.3.0")]
[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[NUnit.Framework.TestFixtureAttribute()]
[NUnit.Framework.DescriptionAttribute("Login")]
public partial class LoginFeature
{
private static TechTalk.SpecFlow.ITestRunner testRunner;
#line 1 "Login.feature"
#line hidden
[NUnit.Framework.TestFixtureSetUpAttribute()]
public virtual void FeatureSetup()
{
testRunner = TechTalk.SpecFlow.TestRunnerManager.GetTestRunner();
TechTalk.SpecFlow.FeatureInfo featureInfo = new TechTalk.SpecFlow.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "Login", "In order to login to the application\r\nAs a user\r\nI want to have my domain passwor" +
"d authenticated", ((string[])(null)));
testRunner.OnFeatureStart(featureInfo);
}
[NUnit.Framework.TestFixtureTearDownAttribute()]
public virtual void FeatureTearDown()
{
testRunner.OnFeatureEnd();
testRunner = null;
}
public virtual void ScenarioSetup(TechTalk.SpecFlow.ScenarioInfo scenarioInfo)
{
testRunner.OnScenarioStart(scenarioInfo);
}
[NUnit.Framework.TearDownAttribute()]
public virtual void ScenarioTearDown()
{
testRunner.OnScenarioEnd();
}
[NUnit.Framework.TestAttribute()]
[NUnit.Framework.DescriptionAttribute("My login and password is authentic")]
[NUnit.Framework.CategoryAttribute("mytag")]
public virtual void MyLoginAndPasswordIsAuthentic()
{
TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("My login and password is authentic", new string[] {
"mytag"});
#line 7
this.ScenarioSetup(scenarioInfo);
#line 9
testRunner.Given("I am a valid user");
#line hidden
TechTalk.SpecFlow.Table table1 = new TechTalk.SpecFlow.Table(new string[] {
"Field",
"Value"});
table1.AddRow(new string[] {
"Name",
"a.w"});
table1.AddRow(new string[] {
"Password",
"correctpassword"});
#line 10
testRunner.When("I enter the following information", ((string)(null)), table1);
#line 15
testRunner.And("I click the \"Login\" button");
#line 16
testRunner.Then("The main application window should launch");
#line hidden
testRunner.CollectScenarioErrors();
}
[NUnit.Framework.TestAttribute()]
[NUnit.Framework.DescriptionAttribute("My login and password are not authentic")]
[NUnit.Framework.CategoryAttribute("mytag")]
public virtual void MyLoginAndPasswordAreNotAuthentic()
{
TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("My login and password are not authentic", new string[] {
"mytag"});
#line 20
this.ScenarioSetup(scenarioInfo);
#line 21
testRunner.Given("I am not a valid user");
#line hidden
TechTalk.SpecFlow.Table table2 = new TechTalk.SpecFlow.Table(new string[] {
"Field",
"Value"});
table2.AddRow(new string[] {
"Name",
"a.w"});
table2.AddRow(new string[] {
"Password",
"password"});
#line 22
testRunner.When("I enter the following information", ((string)(null)), table2);
#line 26
testRunner.And("I click the \"Login\" button");
#line 27
testRunner.Then("The main application window should not launch");
#line hidden
testRunner.CollectScenarioErrors();
}
}
}
#endregion
它具有一些相似的特征文件,因为我可以看到一些引用的步骤,但有很多的噪音在这里。我一直在寻找TheCamronBute YouTube视频:
http://www.youtube.com/watch?v=Pptwj55P03s
并在VID上述[非决定性的文件]所生成的文件不具有的行号的引用,并且通常出现清洁器 - 直观它 t是那么很容易将存根方法复制并粘贴到定义文件中并创建测试。
从我上面的文件列表中,我不清楚该列表的哪一部分复制到定义文件中。
当我将完整列表复制到定义文件时,会出现重复错误。
其他人碰到这个问题 - 我想知道是否我的版本的specflow,我绑在1.3.3?
Lee是正确的,您需要添加下一步。我推荐观看Rob Conery在Tekpub上的BDD介绍http://tekpub.com/view/concepts/5 – bitsprint
@bitsprint:链接已经死亡。 –
Tekpub被Pluralsight收购。看起来你仍然可以在http://youtu.be/SVwBz-ZTliw看到原始视频 – bitsprint