3

I'm trying out Specflow for the first time, and have created a VS2010 project with a reference to TechTalk.SpecFlow, as well as nunit.framework. I've added a sample Feature file:

Feature: Addition
    In order to avoid silly mistakes
    As a math idiot
    I want to be told the sum of two numbers

@mytag
Scenario: Add two numbers
    Given I have entered 50 into the calculator
    And I have entered 70 into the calculator
    When I press add
    Then the result should be 120 on the screen

When I execuyte the test (using TestDriven.Net), I get the following error:

Test 'T:SpecFlowFeature1' failed: Couldn't find type with name 'SpecFlowFeature1'
System.Exception: Couldn't find type with name 'SpecFlowFeature1'
at MutantDesign.Xml.Documentation.MemberInfoUtilities.FindMemberInfo(Assembly assembly, String cref)
at TestDriven.TestRunner.AdaptorTestRunner.Run(ITestListener testListener, ITraceListener traceListener, String assemblyPath, String testPath)
at TestDriven.TestRunner.ThreadTestRunner.Runner.Run()

Anyone know what I'm missing?

4

2 回答 2

5

实际上可以追溯到我是如何运行测试的。右键单击“ .feature”文件(或该文件中的任何位置)并选择“运行测试”会导致错误。右键单击底层“ .feature.cs”文件并选择正确执行的“运行测试”。看起来 TestDriven.Net 无法“理解”“*.feature”文件。

于 2010-09-09T16:01:35.590 回答
0

我通常在我的引用文件夹中启动“找不到类型...”错误,并确保我引用的库被正确引用并且被引用的版本没有过时。

此外,请确保您的 SpecFlowFeature1 类没有被错误地声明为私有。Visual Studio 将新类(默认情况下)创建为私有类,如果您没有将类指定为公共类,它将保持私有,并且对外部项目不“可见”。

于 2010-09-09T15:48:42.277 回答