You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Cucumber在IDEA中出现‘No features found at "path"’报错求助

Troubleshooting "No features found" Error in Test Runner

Hey there! Let's work through fixing that persistent "No features found" error you're seeing—this is a super common gotcha with behavior-driven test frameworks like Cucumber, so I’ve got a list of actionable checks to try:

1. Double-Check Feature File Paths & Naming

  • First, confirm your .feature files are stored in the directory your test runner is configured to scan. Most frameworks default to src/test/resources/features or a top-level features folder—if yours are elsewhere, you’ll need to explicitly point the runner there.
  • Verify filenames are correct: they must end with .feature (not .features or a typo like .featrue), and avoid special characters or spaces that might break path resolution.
  • If you’re using the --features parameter, make sure the path is either an absolute path, or a relative path from your project’s root directory. For example:
    # Correct relative path example
    cucumber --features ./src/test/resources/features/checkout.feature
    
    A tiny mistake like missing a ./ or misspelling a folder name will cause the runner to miss your files entirely.

2. Validate Feature File Syntax

Even a tiny syntax error can make the runner refuse to recognize your feature file. Check for:

  • Properly capitalized keywords (e.g., Feature:, Scenario:, Given—not lowercase)
  • Correct indentation (scenarios and steps should be indented under the Feature block)
  • No missing colons after keywords (easy typo to make!)
  • If you’re using an IDE, install a BDD plugin (like Cucumber for IntelliJ) — it’ll highlight syntax errors in real time.

3. Review Test Runner Configuration

If you’re using a dedicated test runner class (common in Java/Kotlin projects), double-check the features path in your annotations:

@CucumberOptions(
    features = "src/test/resources/features", // Ensure this path matches your actual folder structure
    glue = "com.yourcompany.stepdefinitions"
)
public class TestRunner {}

For command-line runs, make sure you’re not missing critical parameters like --glue (to point to your step definitions) — while this won’t cause "No features found" directly, a misconfigured glue path can sometimes mask underlying file discovery issues.

4. Confirm Build Tool & Project Structure Settings

  • If you’re using Maven or Gradle, ensure your .feature files are in a directory marked as a resource folder. For Maven, src/test/resources is default, but if you’ve placed files elsewhere, add a resource configuration to your pom.xml:
    <build>
        <testResources>
            <testResource>
                <directory>src/test/custom-features</directory>
            </testResource>
        </testResources>
    </build>
    
  • Check that your .gitignore or build tool settings aren’t excluding .feature files—accidental exclusion means they won’t be copied to the classpath, so the runner can’t find them.

5. Clean Cache & Rebuild

Sometimes old build cache or IDE glitches cause files to be invisible to the runner:

  • Run a clean build: For Maven, mvn clean test-compile; for Gradle, ./gradlew clean testClasses
  • Restart your IDE to clear any cached file indexes

Since you mentioned having screenshots of both with/without the --features parameter, take a close look at the working directory in those screenshots—if you’re running the command from a subfolder instead of the project root, your relative paths will be wrong.

内容的提问来源于stack exchange,提问作者Anton Zarovskiy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 08:27:21