黄瓜与Java和Selenium错误地报告了重复的步骤定义。

huangapple 未分类评论50阅读模式
英文:

Cucumber with Java and Selenium falsely reports duplicate step definitions

问题

我尝试运行 Cucumber 测试时,开始遇到以下错误:

  1. 未找到任何测试
  2. 主线程异常 "main" cucumber.runtime.DuplicateStepDefinitionException:文件中的 e2e.brukerveiledning.BrukerveiledningSteps.jegGårTilLivssituasjonForAaSeNyFunksjonFor(String) 和文件中的 e2e.brukerveiledning.BrukerveiledningSteps.jegGårTilLivssituasjonForAaSeNyFunksjonFor(String) 存在重复的步骤定义:/home/frank/Desktop/saksbehandling/e2e/cucumber/target/test-classes/ /home/frank/Desktop/saksbehandling/e2e/cucumber/target/test-classes/ 中。

现在,我真的不理解这个错误信息。它声称存在重复的步骤定义,并指向一个文件夹,将其称为文件。而且,这是一个输出文件夹,而不是包含实际源文件的文件夹。那么任何内容如何会“重复”呢?

而且这适用于许多直到现在都正常工作的步骤和定义。每次我注释掉一个所谓的“重复”项,它就会继续声称另一个步骤是重复的。对于每一个这样的步骤,搜索结果只有一个。

有什么想法吗?

而且它声称重复的步骤定义是没有重复的。搜索该名称只会找到一个结果。

对于上面的示例:

  1. @Når("^jeg går til livssituasjon for aa se ny funksjon for \"([^\"]*)\"$")
  2. public void jegGårTilLivssituasjonForAaSeNyFunksjonFor(String sakTag) {
  3. long sakId = ScenarioState.getSakId(sakTag);
  4. navigationPage.gaTilPath("/sak/" + sakId + "/livssituasjon", false);
  5. }

搜索此步骤定义时,只会找到一个匹配项:

黄瓜与Java和Selenium错误地报告了重复的步骤定义。

如果我注释掉此定义并尝试运行测试,它会继续执行相同的声称,得到相同的结果。

因此,显然某些更深层次的错误出现了,因为错误声称完全是错误的(至少看起来是如此)。

此外,在首次出现错误时(在 Jenkins 中,并在之后本地重现),某些测试运行良好,而其他一些则不行。但在尝试运行其中一个失败的测试之后,所有其他测试突然也失败了。

英文:

I've started getting this error when trying to run a cucumber test:

  1. No tests were found
  2. Exception in thread "main" cucumber.runtime.DuplicateStepDefinitionException: Duplicate step definitions in e2e.brukerveiledning.BrukerveiledningSteps.jegGårTilLivssituasjonForAaSeNyFunksjonFor(String) in file:/home/frank/Desktop/saksbehandling/e2e/cucumber/target/test-classes/ and e2e.brukerveiledning.BrukerveiledningSteps.jegGårTilLivssituasjonForAaSeNyFunksjonFor(String) in file:/home/frank/Desktop/saksbehandling/e2e/cucumber/target/test-classes/

Now, I really don't understand this error message. It claims there is a duplicate step definition, and it points to a folder, calling it a file. Also, it's an output folder, and not a folder containing actual source files. So how does anything get "duplicate"?

And this goes for a lots of steps and definitions that have been working fine up until now. Every time I comment out one alleged "duplicat", it goes on to claim that another step is a duplicate. And for every single one of them, a search yields one and only one result.

Any ideas?

And the step definition it claims is duplicated IS NOT DUPLICATED. A search for the name yields only one result.

For the example above:

  1. @Når("^jeg går til livssituasjon for aa se ny funksjon for \"([^\"]*)\"$")
  2. public void jegGårTilLivssituasjonForAaSeNyFunksjonFor(String sakTag) {
  3. long sakId = ScenarioState.getSakId(sakTag);
  4. navigationPage.gaTilPath("/sak/" + sakId + "/livssituasjon", false);
  5. }

When searching for this step definition, only one match is found:

黄瓜与Java和Selenium错误地报告了重复的步骤定义。

If I comment out this definition and try to run the test(s), it moves on to the next one with the same claim, yielding an identical result.

So there's clearly some deeper error somewhere, since the error claim is completely bogues (seemingly, at least).

Also, when the error first occurs (in Jenkins, and reproduced locally afterwards), some tests run fine and som don't. But after trying to run one of those that failed, all other tests suddenly fail too.

huangapple
  • 本文由 发表于 2020年5月5日 02:52:23
  • 转载请务必保留本文链接:https://java.coder-hub.com/61599500.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定