'How to validate invalid Cucumber/Gherkin .feature file in build?

If I create step in Cucumber .feature file that is not implemented I get snippet in logs. But if I make error in .feature file like starting new line with "Andd" or with anything but keywords (given, when..) then I get error in IntelliJ "Unexpected element" which is underlined and that's great. But despite that when I build project I get "success build". Also when I go further and run Cucumber tests I get "0 Scenarios, 0 Steps found." and no explanation why.

Is there any build parameter that can be added to mark such build unsuccessful? Is there any way to point to such errors?

Edit: when running from cmd 'mvn test..' I get nice stack trace. Problem is only when running in Intellij > Run/Debug Configuration. Sample .run.xml that I am using:

<component name="ProjectRunConfigurationManager">
  <configuration default="false" name="Feature: testFeed" type="CucumberJavaRunConfigurationType" factoryName="Cucumber java" nameIsGenerated="true">
    <option name="CUCUMBER_CORE_VERSION" value="5" />
    <option name="FILE_PATH" value="$PROJECT_DIR$/src/test/resources/features/testFeed.feature" />
    <option name="GLUE" value="com.testing.stepdefiniton" />
    <option name="MAIN_CLASS_NAME" value="io.cucumber.core.cli.Main" />
    <module name="testing" />
    <option name="PROGRAM_PARAMETERS" value=" --plugin org.jetbrains.plugins.cucumber.java.run.CucumberJvm5SMFormatter" />
    <shortenClasspath name="NONE" />
    <option name="SUGGESTED_NAME" value="Feature: testFeed" />
    <option name="VM_PARAMETERS" value="-Dspring.profiles.active=local -Dcucumber.filter.tags=&quot;@test&quot;" />
    <option name="WORKING_DIRECTORY" value="$MODULE_WORKING_DIR$" />
    <extension name="coverage">
      <pattern>
        <option name="PATTERN" value="io.cucumber.core.cli.*" />
        <option name="ENABLED" value="true" />
      </pattern>
    </extension>
    <method v="2">
      <option name="Make" enabled="true" />
    </method>
  </configuration>
</component>


Solution 1:[1]

There are two parts to this question

  1. You usage of IntelliJ (I can't help you with this)
  2. Your usage of Cucumber (maybe I can help here)

Cucumber is telling you that it can't find any scenarios or any steps. Its not going to contribute until you can fix that. You need to either try running Cucumber from the command line, or configure IntelliJ correctly so it can find the features and steps when running cucumber.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 diabolist