0

我很难弄清楚我在 VS2012 和/或 VS2010 中的规范流程功能出了什么问题

如果该字符包含在步骤表达式中的其他任何位置,我根本无法在步骤中使用单个字符作为参数

它永远无法正确解析,我尝试过各种方法,包括使用引号等,但似乎无法使用单个字符。

请有人确认这是预期的或已知的问题,甚至我只是做错了什么?

我尝试过使用 SpecFlow 1.9.1 和 1.9.2(最新版本),但都不起作用。

显示我的问题的一个简单示例是以下功能/步骤

特征

Feature: Test1
    In order to check the id of an object using a character
    As a frustrated developer
    I want to define a step with a single char as a parameter

@mytag
Scenario: Test single char param of character existing in phrase
    Given I have an array of 8 characters   
    Then the array should contain the character a

Scenario: Test single char param of character not existing in phrase
    Given I have an array of 8 characters   
    Then the array should contain the character z

脚步

public class TestSpecFlow1Steps
{
    char[] charArray = new char[] { 'a', 'b', 'c', 'd', 'e', 'x', 'y', 'z' };

    [Given(@"I have an array of (.*) characters")]
    public void CheckArrayCount(int arrayCount)
    {
        Assert.AreEqual(charArray.Length, arrayCount);
    }


    [Then(@"the array should contain the character (.*)")]
    public void CheckCharaExists(char val)
    {
        Assert.AreEqual(true, charArray.Contains(val));
    }

}

对此的任何帮助将不胜感激。

谢谢

4

1 回答 1

0

我认为这是 SpecFlow 的 VS 插件中的一个已知错误。他们用来应用格式的正则表达式找到了错误的字符,如第一个 Then 所示。但是,这并不意味着您的测试有任何问题。正如您在此处看到的,测试通过了。

在此处输入图像描述

(哎呀,刚刚发现你在上面说的正是,当你更新你的问题时,我会更新这个答案)

于 2013-04-23T17:12:50.310 回答