2017-02-06 1 views
1

단계 정의에서 단계를 호출하려고하는데이를 수행 할 때 SpecFlowException이 표시됩니다. 다음 예에서단계 정의에서 호출하는 Specflow가 TechTalk.SpecFlow.SpecFlowException을 throw합니다. 단계 클래스의 컨테이너가 초기화되지 않았습니다.

봐 :

[Binding] 
public class MySteps: Steps 
{ 
    [Given("Doing some actions, getting (.*) and (.*)")] 
    public void DoingSomeActionsGettingValueAndOtherValue(int a, int b) 
    { 
     Given($"I pass first integer {a} and second integer {b}"); 
    } 

    [Given(@"I pass first integer (.*) and second integer (.*)")] 
    public void ThenIPassFirstIntegerValueAndSecondIntegerValue(int a, int b) 
    { 
     AreEqual(a, b); 
    } 
} 

예외는 다음

-> error: Container of the steps class has not been initialized! 
TechTalk.SpecFlow.SpecFlowException: Container of the steps class has not been initialized! 
    at TechTalk.SpecFlow.Steps.AssertInitialized() 
    at TechTalk.SpecFlow.Steps.get_TestRunner() 
    at TechTalk.SpecFlow.Steps.Given(String step) 

나는이 특정 오류가있는 이유 누군가가 설명 할 수이며 어떻게 해결합니까? 나는 문서화에 많은 도움을 찾을 수 없었다.

답변

0

새 프로젝트에서 오류를 재현하려했지만 성공했습니다.

내 specflow 클래스는 당신에서 복사

:

using System; 
using System.Collections.Generic; 
using System.Linq; 
using NUnit.Framework; 
using TechTalk.SpecFlow; 

namespace ClassLibrary3 
{ 
    [Binding] 
    public class MySteps : Steps 
    { 
     [Given("Doing some actions, getting (.*) and (.*)")] 
     public void DoingSomeActionsGettingValueAndOtherValue(int a, int b) 
     { 
      Given($"I pass first integer {a} and second integer {b}"); 
     } 

     [Given(@"I pass first integer (.*) and second integer (.*)")] 
     public void ThenIPassFirstIntegerValueAndSecondIntegerValue(int a, int b) 
     { 
      Assert.AreEqual(a, b); 
     } 
    } 
} 

을 그리고 이것은 기능 파일입니다

Feature: SpecFlowFeature1 
    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 Doing some actions, getting 1 and 1 

내 조언은 새 프로젝트에서뿐만 아니라 오류를 재현하려고하고, 거기에서 성공하면, 질문에 게시하지 않은 코드에 버그가 숨겨져 있어야합니다.

관련 문제