मैं Nunit साथ SpecFlow उपयोग कर रहा हूँ और मैं सेटअप करने के लिए मेरी वातावरण TestFixtureSetUpAttribute का उपयोग कर परीक्षण कोशिश कर रहा हूँ का सम्मान नहीं करते, लेकिन यह कभी नहीं कहा जाता है।Specflow TestFixtureSetUpAttribute
मैं पहले से ही MSTests और ClassInitialize विशेषता का उपयोग करने की कोशिश की, लेकिन एक ही होता है। समारोह नहीं कहा जाता है।
कोई भी विचार क्यों?
[Binding]
public class UsersCRUDSteps
{
[NUnit.Framework.TestFixtureSetUpAttribute()]
public virtual void TestInitialize()
{
// THIS FUNCTION IS NEVER CALLER
ObjectFactory.Initialize(x =>
{
x.For<IDateTimeService>().Use<DateTimeService>();
});
throw new Exception("BBB");
}
private string username, password;
[Given(@"I have entered username ""(.*)"" and password ""(.*)""")]
public void GivenIHaveEnteredUsernameAndPassword(string username, string password)
{
this.username = username;
this.password = password;
}
[When(@"I press register")]
public void WhenIPressRegister()
{
}
[Then(@"the result should be default account created")]
public void ThenTheResultShouldBeDefaultAccountCreated()
{
}
समाधान:
[Binding]
public class UsersCRUDSteps
{
[BeforeFeature]
public static void TestInitialize()
{
// THIS FUNCTION IS NEVER CALLER
ObjectFactory.Initialize(x =>
{
x.For<IDateTimeService>().Use<DateTimeService>();
});
throw new Exception("BBB");
}
private string username, password;
[Given(@"I have entered username ""(.*)"" and password ""(.*)""")]
public void GivenIHaveEnteredUsernameAndPassword(string username, string password)
{
this.username = username;
this.password = password;
}
[When(@"I press register")]
public void WhenIPressRegister()
{
}
[Then(@"the result should be default account created")]
public void ThenTheResultShouldBeDefaultAccountCreated()
{
}
धन्यवाद, यह काम करते हैं। मुझे केवल अपने फ़ंक्शन को स्थिर में बदलने की आवश्यकता है – muek