首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >NUnit、TestDriven.NET、WatiN和Specflow

NUnit、TestDriven.NET、WatiN和Specflow
EN

Stack Overflow用户
提问于 2012-02-20 09:39:35
回答 1查看 644关注 0票数 1

我正在尝试使用Specflow、NUnit和WatiN进行一些BDD测试。我正在使用TestDriven.NEt来运行测试。这是我的第一个测试:

代码语言:javascript
复制
[Binding]
    [TestFixture, RequiresSTA]
    public class RegisterUserSteps
    {
        private IE _ie = new IE();

        [When(@"the user visits the registration page")]
        public void WhenTheUserVisitsTheRegistrationPage()
        {
            _ie.GoTo("http://localhost:1064/Register/"); 
        }


        [When(@"enter the following information")]
        public void WhenEnterTheFollowingInformation(Table table)
        {
            foreach(var tableRow in table.Rows)
            {
                var field = _ie.TextField(Find.ByName(tableRow["Field"])); 

                if(!field.Exists)
                {
                    Assert.Fail("Field does not exists!");
                }

                field.TypeText(tableRow["Value"]);
            }
        }

        [When(@"click the ""Register"" button")]
        public void WhenClickTheRegisterButton()
        {
            ScenarioContext.Current.Pending();
        }

        [Then(@"the user should be registered")]
        public void ThenTheUserShouldBeRegistered()
        {
            ScenarioContext.Current.Pending();
        }

    }

问题是,它永远不会进入

代码语言:javascript
复制
 [When(@"enter the following information")]
            public void WhenEnterTheFollowingInformation(Table table)

它只是启动浏览器并执行第一步。我是不是遗漏了什么?

EN

回答 1

Stack Overflow用户

发布于 2012-02-20 10:03:57

如果不看测试,你似乎错过了一个重要的步骤(给定的)。通常是这样的:

代码语言:javascript
复制
Given I go to some page
And all the set up data are available - optional
When I enter the following info
And I click "Register" button
Then I see something

这些步骤基本上是GWT (给定、何时、然后)。这是小黄瓜语言,所以如果你在谷歌上搜索它,你会看到更多的信息。如果给定步骤有多个内容,则必须使用And、example、When ...... And.......而不是When...... When........

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9355182

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档