specflow

Specflow error: Force regenerate steps possible?

半世苍凉 提交于 2019-12-02 20:12:37
Is it possible to "force" regenerate step definitions for a specflow feature file? I have created this feature file but cannot generate all steps. Am getting a message that all steps are already bound but when I run the test, I get an error that the same steps are not bound. I have cleared everything and recreated both feature and step definition but now I cant event generate ALL the steps because specflow says they are bound already. SpecFlow creates a .cache file in your Temp folder that holds these bindings to speed things up. If that file gets out of whack, you can delete it : Exit Visual

How do I get SpecFlow to expect an exception?

青春壹個敷衍的年華 提交于 2019-12-02 19:01:56
I'm using SpecFlow, and I'd like to write a scenario such as the following: Scenario: Pressing add with an empty stack throws an exception Given I have entered nothing into the calculator When I press add Then it should throw an exception It's calculator.Add() that's going to throw an exception, so how do I handle this in the method marked [Then] ? Great question. I am neither a bdd or specflow expert, however, my first bit of advice would be to take a step back and assess your scenario. Do you really want to use the terms "throw" and "exception" in this spec? Keep in mind the idea with bdd is

How to read test run settings parameter value in specflow tests?

做~自己de王妃 提交于 2019-12-02 15:51:11
问题 We use .runsettings file in visual studio for running specflow tests. There we have certain parameters configured. I need to access those parameter values at run time to use in specflow test methods. I tried accessing those via TestContext as below [ClassInitialize] public static void Initialize(TestContext testContext) { var value= Convert.ToString(testContext.Properties["testParameter1"]); } I am getting the exception for testcontext instance at run time as below. "System

How to read test run settings parameter value in specflow tests?

我怕爱的太早我们不能终老 提交于 2019-12-02 07:30:16
We use .runsettings file in visual studio for running specflow tests. There we have certain parameters configured. I need to access those parameter values at run time to use in specflow test methods. I tried accessing those via TestContext as below [ClassInitialize] public static void Initialize(TestContext testContext) { var value= Convert.ToString(testContext.Properties["testParameter1"]); } I am getting the exception for testcontext instance at run time as below. "System.NullReferenceException: 'Object reference not set to an instance of an object.'" Environment Visual Studio Enterprise

Is it valid to have specflow features depending on other features?

我只是一个虾纸丫 提交于 2019-12-02 07:24:15
问题 I want to write an acceptance test along the lines of given the first test has run when I do this new test then this new test passes This is because the first test will leave the data in a valid state to perform the next test Can I do this in Specflow? 回答1: yes you can do this in specflow, but with a slight caveat. this approach will not run one scenario, then run the other, it will run the first scenario on its own, then the dependent scenario will run the first scenario again followed by

Is it valid to have specflow features depending on other features?

丶灬走出姿态 提交于 2019-12-02 04:53:31
I want to write an acceptance test along the lines of given the first test has run when I do this new test then this new test passes This is because the first test will leave the data in a valid state to perform the next test Can I do this in Specflow? yes you can do this in specflow, but with a slight caveat. this approach will not run one scenario, then run the other, it will run the first scenario on its own, then the dependent scenario will run the first scenario again followed by the second scenario. The order of these may not be deterministic. We have avoided this issue by @ignore the

How to transform Spec-flow table data into different values

北城以北 提交于 2019-12-01 20:44:31
I need to transform Spec-flow table data that we get via table.CreateInstance() or table.CreateSet() . I am using Spec flow for DB testing and in some cases, Table field values needs to be mapped to different values as DB tables are storing codes instead of the the values we have entered in tables of feature files. I do not want to include the codes in feature files as it reduces the readability. For example, If I have entered Single for status as mentioned below, I want it to be mapped or transform to S in the data transfer object / POCO. What is the best approach ? Thanks in advance. Given I

Specflow calling steps within steps causes “No matching step definition” error

感情迁移 提交于 2019-12-01 19:35:09
I am following the technique outlined here using a step defined like [Given("some base scenario has happened")] public void SomeBaseScenarioHasHappened() { Given("some condition"); And("some action"); When("some result"); } from a scenario like Scenario: Some dependant scenario Given some condition And some base scenario has happened When some other action Then some other result However the step When some other condition produces the following error -> No matching step definition found for the step. Use the following code to create one: [When(@"some other condition")] public void Whensome

Specflow setup to Share Hooks and Step Definitions Across VS Projects

血红的双手。 提交于 2019-12-01 12:50:27
Currently working on a series of projects that are contained within one solution in VS2017. Each project is a specflow project, within one solution. I would like to setup the Hooks.cs file such that it's valid for any test within the entire solution, not just the project. I'd also like to make step definitions from one project available to the other projects as a base or utility step definition. How would I go about structuring specflow to make this possible? You can use steps and hooks from different assemblies. You can add in the configuration a list of additional step assemblies like this:

Why do my SpecFlow tests not show up in Visual Studio Test window?

▼魔方 西西 提交于 2019-12-01 04:46:55
I have gone through the Getting Started tutorial for SpecFlow. Everything worked fine except that I have the @SpecRun test because I have not entered a demo key. But in our main project we use NUnit instead of SpecFlow+ Runner. So I tried to mimic that project. If you use NUnit you won't need the demo key. So I changed the Unit Test Provider to: <specFlow> <unitTestProvider name="NUnit" /> </specFlow> I also compared my tutorial references to the main project's references. I find that I can take out TechTalk.SpecRun and the project will still compile. Of course TechTalk.SpecFlow is needed. If