Skip to main content

How to achieve more unique or readable test names when using excel as a test data source in Specflow ExternalData

Comments

6 comments

  • Andreas Willich

    Testname generation also depends on the used test runner. Which one are you using?

    0
  • Bijo Punnoose

    I am using mstest. The view in the Test Explorer as well as when running from ADO is as below:

    but when the values are within the Table of feature file and no excel datasource exists. The "example testidentifier" column is the first column and unique all get populated correctly in the test name as below:

    0
  • Bijo Punnoose

    I just realised by accident this could be an issue with the latest specflow version 3.9.74. With this version it doesnt matter if the example source is excel or within a feature file the unique name seems to disappear and the long unreadable test names get generated.

    When I downgarde it to a lower version it works fine but then I cannot add specflow external data as I keep getting the error

    The "GenerateFeatureFileCodeBehindTask" task failed unexpectedly.
    System.IO.FileNotFoundException: Could not find file 'C:\VSO\Trade0TronCloud\Trade0TronCloudIntergationTests\testdata.json'.
    File name: 'C:\VSO\Trade0TronCloud\Trade0TronCloudIntergationTests\testdata.json'
       at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
       at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
       at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
       at SpecFlow.ExternalData.SpecFlowPlugin.TestDataProvider..ctor(ProjectSettings projectSettings) in D:\a\1\s\Plugins\SpecFlow.ExternalData\SpecFlow.ExternalData.SpecFlowPlugin\TestDataProvider.cs:line 14    Trade0TronCloud.IntegrationTests    C:\Users\BI844734\.nuget\packages\specflow.tools.msbuild.generation\3.4.31\build\SpecFlow.Tools.MsBuild.Generation.targets    93    

    0
  • Andreas Willich

    Ok, please open an issue on GitHub https://github.com/specflowoss/specflow with a project to reproduce this issue.

    0
  • Bijo Punnoose

    Hi Andreas, I tried to reproduce the issue in a separate project.

    I unfortunately can never get the custom unique names to work even after downgrading specflow. I see your latest comments in stackoverflow https://stackoverflow.com/questions/64331788/specflow-scenario-outline-change-auto-generated-test-name

    Is this still the case? A simple example as below:

    Scenario Outline: Example
        Given I am a user
        When I enter <x> as an amount
        Then the result should be <result>
        Examples:
            | example description   | x | result |
            | Example Description 1 | 3 | 3      |
            | Example Description 2 | 1 | 1      |
    

    This should result in the following test names:

    Example_ExampleDescription1
    Example_ExampleDescription2
    

    The issue though is we see the unreadable format being displayed:

    Example("Example Description 1","3","3",null)
    Example("Example Description 2","1","1",null)
    

    This used to be working in the previous versions of specflow not sure why it isnt working now. This is quite important in multiple places I have worked and would be really good if can be fixed. I am using Nunit runner for this.

    1
  • Kyle Noll

    Andreas Willich Just wanted to piggy back on this thread and see if there were any updates available or being looked into for something to control the automatically generated test case names in this way?

    I see in the discussion of that bug you linked that to it might not be possible for the specflow side to get the names to be more readable and it is just how NUnit works, is this the case?

    0

Please sign in to leave a comment.

Powered by Zendesk