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

多模块Java项目中Cucumber特性文件无法关联其他模块的步骤定义问题求助

多模块Java项目中Cucumber特性文件无法关联其他模块的步骤定义问题求助

各位大佬好,我现在碰到一个棘手的问题——没法把特性文件映射到另一个模块里的步骤定义上,想请教下大家怎么解决。

我的项目是分成两个Java模块的:第一个模块(api-testing)里放着特性文件和运行器类,第二个模块(rest-commons)里则是测试步骤和对应的定义。

先给大家看看我当前用的运行器代码:

@RunWith ( CucumberWithSerenity.class )
@CucumberOptions ( features = "features/", glue = { "com.kps.api.steps.definitions" }, tags = "@API"
,plugin = { "pretty", "json:target/cucumber-reports/Cucumber.json" },
monochrome = true)

还有我的项目结构:

  • API_TESTING
    -- .idea
    -- api-testing(第一个模块)
    -- feature
    -- feature.file
    -- src
    -- java
    -- Runner.class
    -- rest-commons(第二个模块)
    -- src
    -- main
    -- java
    -- definitions

我试过调整glue参数的各种写法,但结果都一样,每次都会抛出这个错误:

io.cucumber.junit.UndefinedStepException: The step "testing step" is undefined.
You can implement this step using the snippet bellow:

但如果我把步骤定义放到和特性文件同一个模块里,就完全正常,没有任何问题。

有没有大佬遇到过类似的情况,能给我指个方向吗?

备注:内容来源于stack exchange,提问作者Stelian Yolov

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.21 11:20:26