首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >org.jbehave.core.steps.Steps$DuplicateCandidateFound:,那么结果将是$expected

org.jbehave.core.steps.Steps$DuplicateCandidateFound:,那么结果将是$expected
EN

Stack Overflow用户
提问于 2017-09-12 02:40:13
回答 1查看 496关注 0票数 1

我有下面的j既要故事文件:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
Scenario: Scene1
Given the number of <input>
When the result is estimated
Then the result will be <expected>

Examples:
|input|expected|
|1|1|
|2|1, 2|
|3|1, 2, 3|
|4|1, 2, 3, 4|

Scenario: Scene2
Given the number of <input>
When the result is estimated
And the result is sorted in descending order
Then the result will be <expected>

Examples:
|input|expected|
|1|1|
|2|2, 1|
|3|3, 2, 1|
|4|4, 3, 2, 1|

现在我想在我的程序中测试这两种场景,所以我编写了下面的代码:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
import static org.junit.Assert.assertEquals;

import java.util.List;

import org.jbehave.core.annotations.Given;
import org.jbehave.core.annotations.Then;
import org.jbehave.core.annotations.When;

public class EstimatorSteps {
    private Estimator estimator;

    @Given("the number of $input")
    public void given(int input) {
        estimator = new Estimator(input);
    }

    @When("the result is estimated")
    public void when1() {
        estimator.estimate(estimator.getInput());
    }

    @Then("the result will be $expected)
    public void then1(List<Integer> result) {
        assertEquals(estimator.getResult(), result);
    }

    @When("the result is sorted in descending order")
    public void when2() {
        estimator.descending(estimator.getResult());
    }

    @Then("the result will be $expected)
    public void then1(List<Integer> result) {
        assertEquals(estimator.getResult(), result);
    }
}

当我运行测试用例时,我得到以下错误消息:

org.jbehave.core.steps.Steps$DuplicateCandidateFound:,那么结果将是$expected

测试这两种情况的正确方法是什么,我必须在Java代码中做哪些更改。我不想改变我的故事文件。

下面是我的JBehave配置文件:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
import org.jbehave.core.configuration.Configuration;
import org.jbehave.core.configuration.MostUsefulConfiguration;
import org.jbehave.core.io.CodeLocations;
import org.jbehave.core.io.LoadFromClasspath;
import org.jbehave.core.io.StoryFinder;
import org.jbehave.core.junit.JUnitStories;
import org.jbehave.core.reporters.StoryReporterBuilder;
import org.jbehave.core.steps.InjectableStepsFactory;
import org.jbehave.core.steps.InstanceStepsFactory;

import java.util.Arrays;
import java.util.List;

import static org.jbehave.core.io.CodeLocations.codeLocationFromClass;
import static org.jbehave.core.reporters.StoryReporterBuilder.Format.CONSOLE;

public class JBehaveStories extends JUnitStories {

    @Override
    public Configuration configuration() {
        return new MostUsefulConfiguration().useStoryLoader(new LoadFromClasspath(this.getClass()))
                .useStoryReporterBuilder(new StoryReporterBuilder()
                        .withCodeLocation(codeLocationFromClass(this.getClass())).withFormats(CONSOLE));
    }

    @Override
    public InjectableStepsFactory stepsFactory() {
        return new InstanceStepsFactory(configuration(), new EstimatorSteps());
    }

    @Override
    protected List<String> storyPaths() {
        return new StoryFinder().findPaths(CodeLocations.codeLocationFromClass(this.getClass()),
                Arrays.asList("**/*.story"), Arrays.asList(""));
    }
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-09-12 07:41:08

EstimatorSteps类中有两个相同的@ two步骤:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
@Then("the result will be $expected)
public void then1(List<Integer> result) {
    assertEquals(estimator.getResult(), result);
}

....

@Then("the result will be $expected)
public void then1(List<Integer> result) {
    assertEquals(estimator.getResult(), result);
}

JBehave抱怨道:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
DuplicateCandidateFound: THEN the result will be $expected

删除这些方法中的一个,错误将不会出现。

顺便说一句,我想知道这个类是如何编译的,因为Java不应该允许两个具有完全相同签名的重载方法。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46174268

复制
相关文章
did not find expected key
持续集成时报错:yaml: line 18: did not find expected key
拓荒者
2019/08/01
6.3K0
expected `=`,`,`,`;`,`asm` or `attribute`before
仔细查证后发现还是有很大的问题,原因是C语言中并没有bool类型,因此在使用bool类型时,一定要留心:
lexingsen
2022/02/24
5980
expected `=`,`,`,`;`,`asm` or `attribute`before
Expected MultipartHttpServletRequest: is a MultipartResolver configured方案。
1.报错:Expected MultipartHttpServletRequest: is a MultipartResolver configured ?
微风-- 轻许--
2022/04/13
6350
<statement> or DELIMITER expected, got ‘id‘
一、idea mybatis错误信息 <statement> or DELIMITER expected, got ‘id’ PS:idea mybatis报错,很明显是idea配置错误,如图
全栈程序员站长
2022/11/17
3K0
<statement> or DELIMITER expected, got ‘id‘
LightOj_1364 Expected Cards
  每次抽一张牌, 问抽到C张梅花, D张方块, H张红桃, S张黑桃所需要的最小次数的期望。
熙世
2019/07/15
3040
Uva_11427 Expect the Expected
  你玩纸牌, 如果当天晚上你赢的局数比例 大于 p, 就去睡觉, 第二天继续。 如果小于等于p, 就去睡觉, 并且以后都不玩了。
熙世
2019/07/15
2920
Expected indentation of 10 spaces but found 20
遇到过两次这个问题,第一次是用vue做商城时,第二次是做mpvue项目时,这是因为安装vue-cli时,直接安装了ESLint。
honey缘木鱼
2019/03/05
4K0
Warning: Expected server HTML to contain a matchin
Warning: Expected server HTML to contain a matching <div> in <div>.在使用Next.js或者React.js进行SSR网站开发时,我们经常会见到这种错误,主要原因是因为SSR脱水和注水过程中发现元素渲染不一致。
用户6256742
2022/09/16
2.3K0
Warning: Expected server HTML to contain a matchin
ValueError: too many values to unpack (expected 2)
原因是字典这个是一个迭代器对象,参考官方文档找到下列说明,字典只支持Key的遍历,,如果想对key,value,则可以使用items方法。 The “implicit” iteration that dictionaries support only iterates over keys.
狼啸风云
2020/07/28
8.3K0
你面试了那么多的Java岗位,结果都怎么样了?
我有朋友经常说,我去试试怎么样?我感觉自己准备的差不多了,我想去投一下美团和滴滴,去试试能不能直接进大公司?
Java架构技术
2019/03/18
5410
未来必将是AI的天下
如果说现代社会是计算机的天下,是软件的天下,相信不会有人质疑。每个人都有的智能手机也是一个计算机,各行各业使用的各种工具软件:打车、财税、制造业……都极大地提升了社会运营的效率。近二十年经济的腾飞,各种软件想必是立下了汗马功劳。
用户7164815
2022/04/12
2450
那么静,那么美,单例模式
首先我们来讲一个故事。二次世界大战的时候,我国有一个著名的战役叫“长沙保卫战”,中国军队指挥官薛岳将军率领第9战区十余万将士,通过所谓的“焦土”战术4次瓦解日军的大规模进攻,给当时的国民党政府打了一针强心剂。这四次战役中最让人难忘的一幕是,面对单兵战斗力是中国军队5倍的日军,人数上虽然占据一定优势,但是只有第10军和第74军两只军队装备了现代化的军械,其余军队都是“汉阳造”的落后装备。薛将军命令第10军反复在湘北、赣北多处阵地来回穿插,面对东西方向出现的多路敌军,帮助装备落后的部队一起防守阵地,让敌人误以为是多支部队,其实薛岳将军只是调动了同一支部队,正是这一单一实例的对象(第10军)在各个战场均发挥出了显著的作用,为第二次长沙战役的全面获胜起了至关重要的作用。
博文视点Broadview
2020/06/12
4930
那么静,那么美,单例模式
GCC: error: expected `)' before 'PRIu64'
printf("UniqID: %"PRIu64"\n", uniq_id); test.cpp:35: error: expected `)' before 'PRIu64' make: *** [test.o] 错误 1 上述错误,gcc编译时需要定义宏__STDC_FORMAT_MACROS,并且必须包含头文件inttypes.h。
一见
2018/08/10
1.5K0
React报错之Expected an assignment or function call
当我们忘记从函数中返回值时,会产生"Expected an assignment or function call and instead saw an expression"错误。为了解决该错误,确保显式地使用return语句或使用箭头函数隐式返回。
chuckQu
2022/09/20
1.6K0
React报错之Expected an assignment or function call
React报错之Expected `onClick` listener to be a function
当我们为元素的onClick属性传递一个值,但是该值却不是函数时,会产生"Expected onClick listener to be a function"报错。为了解决该报错,请确保只为元素的onClick属性传递函数。
chuckQu
2022/08/19
1.1K0
React报错之Expected `onClick` listener to be a function
Incorrect column count: expected 1, actual 2
错误代码 使用JdbcTemplate查询 String sql="SELECT t.industry_code AS item, COUNT (1) AS intValue FROM company_info t GROUP BY industry_code"; List<LineChartShowBean> pollutionCityBeans = trJdbcTemplate.queryForList(sql, LineChartShowBean.class); que
清风冷影
2019/07/03
3.2K0
解决 JSP 页面报错 equal symbol expected
1.报错:org.apache.jasper.JasperException: /WEB-INF/jsp/op/settlement/spRateModify.jsp(368,110) equal symbol expected
微风-- 轻许--
2022/04/13
2.6K0
[Mybatis] xxxMapper.xml 报错 Tag name expected
我们知道,Mybatis 文件的数据库操作都是在 Mapper 文件中实现的,而 Mapper 文件的主体内容也就是 SQL 语句。
做棵大树
2022/09/27
5240
iOS10之Expected App Behaviors
  昨天上架到appStore的时候碰到个问题,构建好后上传到itunesconnect的的包都用不了,
tandaxia
2018/09/27
5270
iOS10之Expected App Behaviors
点击加载更多

相似问题

错误结果将是太长的向量

13

Django ORM: expected不返回预期结果

13

F# --结果类型将是无限错误。

22

Google结果中的链接将是get或post

12

如果存储过程不执行任何操作,那么ORA代码将是什么?

25
添加站长 进交流群

领取专属 10元无门槛券

AI混元助手 在线答疑

扫码加入开发者社群
关注 腾讯云开发者公众号

洞察 腾讯核心技术

剖析业界实践案例

扫码关注腾讯云开发者公众号
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
查看详情【社区公告】 技术创作特训营有奖征文