Skip to content
This repository was archived by the owner on Nov 7, 2019. It is now read-only.

Commit 905ea73

Browse files
erik-inkapoolstajs
authored andcommitted
Updated readme and added sample projects for all supported test frameworks (#35)
Even if support is experimental
1 parent 1785d55 commit 905ea73

File tree

21 files changed

+377
-45
lines changed

21 files changed

+377
-45
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## Ignore Specflow generated code
2+
*.feature.cs
3+
app.config
4+
15
## Ignore Visual Studio temporary files, build results, and
26
## files generated by popular Visual Studio add-ons.
37

README.md

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,35 @@ Wait for the VS extension to support .NET Core projects. In the meantime, I pres
1212

1313
Update your `project.json`:
1414

15-
0. Include [xUnit](https://github.com/xunit/dotnet-test-xunit):
16-
17-
```json
18-
"dependencies": {
19-
"xunit": "2.1.0",
20-
"dotnet-test-xunit": "1.0.0-*"
21-
},
22-
"testRunner": "xunit"
23-
```
15+
0. Include your testrunner of choice
16+
17+
* [xUnit](https://github.com/xunit/dotnet-test-xunit):
18+
19+
```json
20+
"dependencies": {
21+
"xunit": "2.1.0",
22+
"dotnet-test-xunit": "1.0.0-*"
23+
},
24+
"testRunner": "xunit"
25+
```
26+
27+
* [NUnit 3](https://github.com/nunit/dotnet-test-nunit) _(Experimental)_:
28+
```json
29+
"dependencies": {
30+
"NUnit": "3.4.1",
31+
"dotnet-test-nunit": "3.4.0-beta-2"
32+
},
33+
"testRunner": "nunit"
34+
```
35+
36+
* [MsTest](https://www.nuget.org/packages/dotnet-test-mstest/1.1.1-preview) _(Experimental)_:
37+
```json
38+
"dependencies": {
39+
"dotnet-test-mstest": "1.1.1-preview",
40+
"MSTest.TestFramework": "1.0.4-preview"
41+
},
42+
"testRunner": "mstest"
43+
```
2444

2545
0. Include [`SpecFlow.NetCore`](https://www.nuget.org/packages/SpecFlow.NetCore):
2646

@@ -42,7 +62,7 @@ Update your `project.json`:
4262

4363
### Samples
4464

45-
If you build the [samples](https://github.com/stajs/SpecFlow.NetCore/tree/master/samples/) solution, you should see `.feature.cs` files and an `app.config` being generated.
65+
If you build the [samples](https://github.com/stajs/SpecFlow.NetCore/tree/master/samples/) solution, you should see `.feature.cs` files and an `app.config` being generated for each test framework.
4666

4767
## Supported frameworks
4868

@@ -55,7 +75,8 @@ If you build the [samples](https://github.com/stajs/SpecFlow.NetCore/tree/master
5575
### Test frameworks
5676

5777
- [xUnit](https://xunit.github.io/)
58-
- MsTest - _Experimental support added by the community._
78+
- [NUnit 3](http://www.nunit.org/) - _Experimental support added by the community._
79+
- [MsTest](https://blogs.msdn.microsoft.com/visualstudioalm/2016/05/30/announcing-mstest-framework-support-for-net-core-rc2-asp-net-core-rc2/) - _Experimental support added by the community._
5980

6081
## Visual Studio
6182

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("Sample.Website.Tests")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("Sample.Website.Tests")]
13+
[assembly: AssemblyCopyright("Copyright © 2015")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("785bc4a8-774e-45ec-b99b-e8f9bda0ae19")]
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
5+
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
6+
</PropertyGroup>
7+
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
8+
<PropertyGroup Label="Globals">
9+
<ProjectGuid>b26dc82d-df30-4774-abe6-e17b18fedffa</ProjectGuid>
10+
<RootNamespace>Sample.Website.Tests</RootNamespace>
11+
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
12+
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
13+
</PropertyGroup>
14+
<PropertyGroup>
15+
<SchemaVersion>2.0</SchemaVersion>
16+
</PropertyGroup>
17+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
18+
<ProduceOutputsOnBuild>True</ProduceOutputsOnBuild>
19+
</PropertyGroup>
20+
<ItemGroup>
21+
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
22+
</ItemGroup>
23+
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
24+
</Project>
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
using Microsoft.VisualStudio.TestTools.UnitTesting;
3+
using Sample.Website.Controllers;
4+
using TechTalk.SpecFlow;
5+
6+
namespace Sample.Website.Tests
7+
{
8+
[Binding]
9+
public class StepDefinitions
10+
{
11+
[Given(@"I am curious")]
12+
public void GivenIAmCurious()
13+
{
14+
//ScenarioContext.Current.Pending();
15+
}
16+
17+
[When(@"I request the version")]
18+
public void WhenIRequestTheVersion()
19+
{
20+
var controller = new HomeController();
21+
ScenarioContext.Current.Add("versionResult", controller.Version());
22+
}
23+
24+
[When(@"I yell '(.*)'")]
25+
public void WhenIYell(string exclamation)
26+
{
27+
var controller = new HomeController();
28+
ScenarioContext.Current.Add("echoResult", controller.Echo(exclamation));
29+
}
30+
31+
[Then(@"the result is content")]
32+
public void ThenTheResultIsContent()
33+
{
34+
var versionResult = ScenarioContext.Current["versionResult"];
35+
Assert.IsTrue(versionResult is ContentResult);
36+
}
37+
38+
[Then(@"the result is constant")]
39+
public void ThenTheResultIsConstant()
40+
{
41+
var versionResult = (ContentResult) ScenarioContext.Current["versionResult"];
42+
Assert.AreEqual(versionResult.Content, HomeController.AppVersion);
43+
}
44+
45+
[Then(@"I hear '(.*)' echoed back")]
46+
public void ThenIHearEchoedBack(string exclamation)
47+
{
48+
var echoResult = (ContentResult) ScenarioContext.Current["echoResult"];
49+
Assert.AreEqual(echoResult.Content, exclamation);
50+
}
51+
}
52+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"version": "1.0.0-*",
3+
"description": "Sample.Website.Tests Class Library",
4+
"authors": [ "stajs" ],
5+
6+
"frameworks": {
7+
"net461": {}
8+
},
9+
10+
11+
"dependencies": {
12+
"Sample.Website": "1.0.0-*",
13+
"SpecFlow": "2.1.0",
14+
"dotnet-test-mstest": "1.1.1-preview",
15+
"MSTest.TestFramework": "1.0.4-preview"
16+
},
17+
18+
"tools": {
19+
"SpecFlow.NetCore": "1.0.0-rc6"
20+
},
21+
22+
"testRunner": "mstest",
23+
24+
"scripts": {
25+
"precompile": [ "dotnet SpecFlow.NetCore" ]
26+
}
27+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Feature: Feature in folder
2+
3+
Scenario: SpecFlow glue files are generated in a folder
4+
Given I am curious
5+
When I request the version
6+
Then the result is constant
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("Sample.Website.Tests")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("Sample.Website.Tests")]
13+
[assembly: AssemblyCopyright("Copyright © 2015")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("785bc4a8-774e-45ec-b99b-e8f9bda0ae19")]

0 commit comments

Comments
 (0)