我尝试在网络上找到的一些指南:
- 生成骑手中的杂种文件
- 使用specflow-3-0-with-rider
- SpecFlow-Steps Generation and General-Rider-Changes
...谢谢您的文档ken。
但是,我无法获取我的方案步骤以链接到我的任何步骤文件。
设置
我相信我已经为最新版本的SpecFlow安装了所有必需的Nuget软件包
nuget安装的Specflow jucreshot
我习惯于与Intellij相连,我们也得到了Specflow C#Visual Studio的工作,但是我只是无法获得连接到Rider的步骤的方案。
nb - 我试图在骑手中使用的项目正在使用Specflow在Visual Studio中工作。
还有其他人能赢得这场战斗吗?
我很想听听如何。
谢谢
更新@ken感谢你的建议。
我尝试了以下两种:
- 手动添加在.csproj for for foruna.cs中添加操作,但在构建后仍无法从功能上达到步骤。
- 包括范围(feature ="(属性
,但不幸的是,没有运气。
- 屏幕截图 - 功能和连接的步骤 - Visual Studio
- 屏幕截图 - 功能和连接的步骤 - 骑手(包括.csproj(
如果这无法解决您的问题,您可以发布.feature和.steps.cs文件的内容。
如下所建议,以下是功能和步骤的内容。
.feature
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
.steps
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提供的步骤之后,创建一个新项目并抛出了例外,我可以确认.cs binding binking works.
。肯,你是一个绅士和天才。谢谢。
其次,我错误地以为Rider将为我提供从.feature到我的Steps.cs代码(Cucumber JVM样式(的方法。我现在知道这尚未得到骑手的支持。
- 这就是为什么我认为装订不起作用的原因!duh。
如果有人找到一个将骑手小黄瓜映射到小黄瓜库的插件,我很想听听。
我能想到的第一件事(我自己做了多次(是忘记您 .steps.cs 文件中的 [Binding]
属性。哦,您可能还想标记[Scope(Feature="")]
属性,只是为了避免歧义。
您可以做的另一件事(如果使用Specflow 3.0及更高(,则包括 .feature.cs 文件,并查看是否解决了您的问题。如果是这样,我将考虑检查 .csproj 文件的正确包含.feature.cs文件。
如果这无法解决您的问题,您可以发布您的内容。
编辑我从头开始,这些是我采取的步骤:
- 创建一个新解决方案
- 创建一个测试项目,选择Nunit作为测试框架
- 安装最新的specflow.nunit和specflow.tools.msbuild.generation
- Nuget软件包(应为版本3.0.220((这将自动安装正确的Specflow Nuget软件包(
- 编辑.csconfig并添加
<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>
- 创建一个.feature文件并粘贴在堆栈溢出问题的内容中
- 构建项目,这应该在测试探险家中显示您的测试运行测试以获取其定义
- 创建一个将定义放入(再次,绑定和范围属性(的类,从测试输出窗口复制这些定义
- 在给定方法中抛出例外
- 重新运行测试,看看是否抛出了异常
ps:您的秘密身份对我来说是安全的。;(