6

I have the following specflow scenario:

Scenario: CasingMentions
    When User mentions everyone with <casing> casing
    Then user should be able to see the message they just sent
    Examples: 
    | casing |
    | lower  |
    | mixed  |
    | upper  |

The step definition is like this, and the method just takes a single string:

[When(@"User mentions everyone with (.*) casing")]

this runs completely fine and everything, but in the test runner on visual studio, it shows that there's a null parameter, so the above scenario will appear in the test runner as 3 separate tests, with names like this:

CasingMentions("lower",null)
CasingMentions("mixed",null)
CasingMentions("upper",null)

In the feature.cs file, this is what it looks like:

    [NUnit.Framework.TestAttribute()]
    [NUnit.Framework.DescriptionAttribute("CasingMentions")]
    [NUnit.Framework.TestCaseAttribute("lower", null)]
    [NUnit.Framework.TestCaseAttribute("mixed", null)]
    [NUnit.Framework.TestCaseAttribute("upper", null)]
    public virtual void CasingMentions(string casing, string[] exampleTags)
    {

I don't think its related to the step definition because I can paste the examples into a scenario that takes no parameters, and it will still do this

Here is a video that shows the problem I am encountering: https://youtu.be/vC87WMFfJ4Y?t=438

Is there any way to get rid of the null? This happens for every single scenario I use example tables for, and it doesn't seem to make a difference if I use scenario or scenario outline. I am using NUnit as my test runner if that matters.

I have also tried adding an extra column with unique values to try to name the test cases that way, but they just appear as another parameter in the bracket.

10
  • you must use the keyword scenario outline if you use example. Check an example toolsqa.com/specflow/… Commented Dec 20, 2019 at 14:46
  • I changed it to Scenario Outline but the same thing is still happening, showing null at the end of the name Commented Dec 20, 2019 at 14:51
  • if you try '<casing>' Commented Dec 20, 2019 at 14:54
  • just tried with quotes around <casing> like you suggested, but it still shows a null parameter after the casing parameter in the test name Commented Dec 20, 2019 at 14:58
  • xmm can you post also the method with the attribute "When User mentions everyone with <casing> casing" ????? If you check the link that i posted maybe need to modify like for example When User enter <username> and <password> [When(@”User enter ‘(.*)’ and ‘(.*)'”)] Commented Dec 20, 2019 at 15:00

1 Answer 1

3

I found out there is not a way to get rid of the last 'null'. The last parameter is used for tags regarding your examples.

MyTest("AA","40","11","mysite.com","ENG","+662154215","HotchocolateService","[email protected]","Insurance","2", null)

if you put a @important tag on your examples:

 @important
    Examples: | data | data2 |

It will be parsed in the testcase attribute:

MyTest("AA","40","11","mysite.com","ENG","+662154215","HotchocolateService","[email protected]","Insurance","2",["important"])

The important tag can be used in regards of prioritizing som testcases to run prior to others.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.