runnerpaul
runnerpaul

Reputation: 7196

Specflow step file doesn't appear to be recognised by feature file

I created a Specflow project which has one feature file, EBIntegrationTest.feature :

Feature: EBIntegrationTest for MF
    Initial test feature

@mytag
Scenario: Subscribe to Market Data EU Topic and write to SQL DB
    Given MD messages are streaming to MF application
    When MF enriches template 304
    Then the enriched messages are then written to an SQL DB server

I then added a step file to my Steps folder:

using System;
using System.Collections.Generic;
using System.Text;

namespace eb_test_tool.Steps
{
    class EBIntegrationTest
    {
        [Given(@"MD messages are streaming to MF application")]
        public void GivenMDMessagesAreStreamingToMFApplication()
        {
            var processInfo = new ProcessStartInfo("C:\\ProgramData\\CME\\Java_SymLinks\\JDK8_x64\\jre\\bin\\java.exe",
                                                   "java -jar .\\Jar\\Injector\\MD-Injector-1.0.jar My.TOPIC")
            {
                CreateNoWindow = true,
                UseShellExecute = false
            };
            Process proc;

            if ((proc = Process.Start(processInfo)) == null)
            {
                throw new InvalidOperationException("Message injector failed to run");
            }

            proc.WaitForExit();
            int exitCode = proc.ExitCode;
            proc.Close();
        }
        
        [When(@"MF enriches template (.*)")]
        public void WhenMFEnrichesTemplate(int p0)
        {
            ScenarioContext.Current.Pending();
        }
        
        [Then(@"The enriched messages are then written to an SQL DB server")]
        public void ThenTheEnrichedMessagesAreThenWrittenToAnSQLDBServer()
        {
            ScenarioContext.Current.Pending();
        }

    }
}

When I run dotnet test it is skipped with this alert:

enter image description here

Am I doing something wrong or should I reference my steps file from the feature file in some way?

Upvotes: 0

Views: 439

Answers (2)

runnerpaul
runnerpaul

Reputation: 7196

I noticed this in my .csproj file. When I removed it the issue was resolved.

<ItemGroup>
    <Compile Remove="Steps\EBSIntegrationTestStepDefinitions.cs" />
</ItemGroup>

Upvotes: 0

Andreas Willich
Andreas Willich

Reputation: 5825

You need to add the [Binding] attribute to your EBIntegrationTest class and make it public.

[Binding]
public class EBIntegrationTest
{
//...
}

Upvotes: 2

Related Questions