我尝试使用 Specflow 设置 JetBrains Rider,遵循我在网上找到的一些指导:
...感谢您提供文档 Ken。
但是,我无法将我的场景步骤链接到我的任何步骤文件。
设置
我相信我已经为最新版本的 SpecFlow 安装了所有必需的 NuGet 包
NuGet installed Specflow packages screenshot
我已经习惯了使用 IntelliJ 的 Cucumber,而且我们还让 SpecFlow C# Visual Studio 正常工作,但我只是无法让场景连接到 Rider 中的步骤。
备注 - 我尝试在 Rider 中使用的项目正在使用 Specflow 在 Visual Studio 中工作。
有没有其他人能够赢得这场战斗?
我很想听听如何。
谢谢
更新
@肯
感谢您的建议。
我尝试了以下两种方法:
但不幸的是,没有运气。
If this does not solve you problem, can you post the content of your .feature and .steps.cs files.
根据建议,以下是功能和 step.cs 文件的内容,它们在 VS 中正确映射。:
。特征
Feature: sampleFeature
In order to avoid silly mistakes
As a math idiot
I want to be told the sum of two numbers
@mytag
Scenario: Add two numbers
Given I have entered 50 into the calculator
And I have entered 70 into the calculator
When I press add
Then the result should be 120 on the screen
。脚步
using System;
using TechTalk.SpecFlow;
namespace SpecFlowPoc.features.sample
{
[Binding, Scope(Feature="sampleFeature")]
public class SampleFeatureSteps
{
[Given(@"I have entered (.*) into the calculator")]
public void GivenIHaveEnteredIntoTheCalculator(int p0)
{
ScenarioContext.Current.Pending();
}
[When(@"I press add")]
public void WhenIPressAdd()
{
ScenarioContext.Current.Pending();
}
[Then(@"the result should be (.*) on the screen")]
public void ThenTheResultShouldBeOnTheScreen(int p0)
{
ScenarioContext.Current.Pending();
}
}
}
谢谢
更新 - 已解决
好的,首先感谢Ken 的帮助和指导。
按照 Ken 提供的步骤创建一个新项目并抛出异常后,我可以确认 .feature 到 step.cs 绑定(bind)有效。
肯,你是一位绅士和天才。谢谢你。
其次,我错误地认为 Rider 会为我提供一种从 .feature 导航到我的 Steps.cs 代码(Cucumber JVM 风格)的方法。我现在知道 Rider 尚不支持此功能。
如果有人找到将 Rider 小 cucumber 映射到小 cucumber 库的插件,我很想听听。
最佳答案
我能想到的第一件事(我自己已经做过多次)是忘记 [Binding]
.steps.cs 文件中的属性。哦,你可能想标记一个 [Scope(Feature="")]
属性也是如此,只是为了避免歧义。
您可以做的另一件事(如果您使用的是 SpecFlow 3.0 及更高版本),是手动包含 .feature.cs 文件并查看是否可以解决您的问题。如果是这种情况,我会考虑检查 .csproj 文件是否包含正确的 .feature.cs 文件。
如果这不能解决您的问题,您能否发布 .feature 和 .steps.cs 文件的内容。
编辑
我从头开始,这些是我采取的步骤:
<Target Name="AfterUpdateFeatureFilesInProject">
<!-- include any generated SpecFlow files in the compilation of the project if not included yet -->
<ItemGroup>
<Compile Include="**\*.feature.cs" Exclude="@(Compile)" />
</ItemGroup>
</Target>
运行测试以获取它们的定义
PS:你的 secret 身份对我来说是安全的。 ;)
关于specflow - 无法使用 Specflow 和 JetBrains Rider 将我的功能绑定(bind)到 Steps,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56715659/