Skip to content

Commit 2ed58f7

Browse files
authored
Merge pull request #24 from geeklearningio/release/0.3.3
Release/0.3.3
2 parents 559a0e3 + 3395d23 commit 2ed58f7

File tree

7 files changed

+51
-45
lines changed

7 files changed

+51
-45
lines changed

NuGet.Config

Lines changed: 0 additions & 6 deletions
This file was deleted.

README.md

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
[![NuGet Version](http://img.shields.io/nuget/v/GeekLearning.Testavior.svg?style=flat-square&label=NuGet:%20Testavior)](https://www.nuget.org/packages/GeekLearning.Testavior/)
2+
[![NuGet Version](http://img.shields.io/nuget/v/GeekLearning.Testavior.Configuration.svg?style=flat-square&label=NuGet:%20Testavior.Configuration)](https://www.nuget.org/packages/GeekLearning.Testavior.Configuration/)
3+
[![Build Status](https://geeklearning.visualstudio.com/_apis/public/build/definitions/f841b266-7595-4d01-9ee1-4864cf65aa73/62/badge)](#)
14
# Testavior
2-
*Testavior* is a set of [NuGet libraries]() to help you develop **Behavior** Tests for **ASP.NET Core**.
5+
*Testavior* is a [lightweight solution](https://www.nuget.org/packages?q=Testavior) to help you develop **Behavior** Tests for **ASP.NET Core**.
36

47
>Behavior Tests are a way of testing your application features applying different types of behaviors to cover a **functional scenario**.
58
@@ -8,8 +11,8 @@ For more information about *Behavior Testing* with ASP.NET Core, please take a l
811

912
### Features
1013
*Testavior* provides 2 libraries:
11-
* **Configuration**: Helps you configure your application to easily integrate behavior tests for your scenarios.
12-
* **Integration**: Provides a featured and highly configurable test environment for your behavior tests:
14+
* **Testavior.Configuration**: Helps you configure your application to easily integrate behavior tests for your scenarios.
15+
* **Testavior**: Provides a featured and highly configurable test environment for your behavior tests:
1316
* Configured Test WebHost
1417
* Configured authentication context
1518
* Test authentication middleware
@@ -22,19 +25,19 @@ For more information about *Behavior Testing* with ASP.NET Core, please take a l
2225

2326
### Installation
2427
On your ASP.NET Core project
25-
* Install the **GeekLearning.SceneTest.Configuration** nuget package
28+
* Install the **GeekLearning.Testavior.Configuration** nuget package
2629
```
2730
> dotnet add package GeekLearning.Testavior.Configuration
2831
```
2932

3033
On your .NET Core Unit Test project
31-
* Install the **GeekLearning.SceneTest** nuget package
34+
* Install the **GeekLearning.Testavior** nuget package
3235
```
3336
> dotnet add package GeekLearning.Testavior
3437
```
3538
* Add your ASP.NET Core web project as a project reference
3639
### Configuration
37-
The Test environment provided by *SceneTest* is based on a **Startup Configuration Service** that let you separate the **Production** environment configuration from the **Test** environment configuration.
40+
The Test environment provided by *Testavior* is based on a **Startup Configuration Service** that let you separate the **Production** environment configuration from the **Test** environment configuration.
3841
This configuration service is represented by a contract **IStartupConfigurationService** which define 3 methods: *Configure, ConfigureEnvironment, ConfigureService* that have to be called within the **Startup Routine** to inject environment dependent configuration.
3942

4043
1 - In your **ASP.NET Core** project:
@@ -55,7 +58,7 @@ This configuration service is represented by a contract **IStartupConfigurationS
5558

5659
var connection = "CONNECTION_STRING";
5760

58-
services.AddDbContext<Data.BloggingContext>(options =>
61+
services.AddDbContext<[EF_DB_CONTEXT]>(options =>
5962
options.UseSqlServer(connection));
6063
}
6164
}
@@ -111,7 +114,7 @@ A specific *IStartupConfigurationService* is required for the **Test** environme
111114
*Testavior* comes with a test specific *IStartupConfigurationService* implementation: **TestStartupConfigurationService** which provide a **Test Environment** full of useful features (see **Features** section).
112115
Of course you can implement your own *Test StartupConfigurationService* (by using the onboard TestStartupConfigurationService or not).
113116

114-
To create a *Test Environment*, just instanciate the **TestEnvironment** class by passing it your ASP.NET Core application *Startup*, your *IStartupConfigurationService* implementation and the type of your EF Core ObjectContext
117+
To create a *Test Environment*, just instanciate the **TestEnvironment** class by passing it your ASP.NET Core application *Startup*, your *IStartupConfigurationService* implementation, the type of your EF Core ObjectContext and the relative path to your ASP.NET Core project (required to resolve MVC views).
115118
```csharp
116119
var testEnvironment = new TestEnvironment<Startup, TestStartupConfigurationService<[EF_DB_CONTEXT]>>(
117120
Path.Combine(System.AppContext.BaseDirectory, @"[PATH_TO_WEB_APP]"));
@@ -120,14 +123,20 @@ var testEnvironment = new TestEnvironment<Startup, TestStartupConfigurationServi
120123
#### API Test
121124
Write your API test by just sending web requests using the *Test Environment*:
122125
```csharp
123-
var response = testEnvironment.Client.GetAsync("/api/data").Result;
124-
response.EnsureSuccessStatusCode();
126+
[TestMethod]
127+
public void ScenarioShouldBeOk()
128+
{
129+
var testEnvironment = new TestEnvironment<Startup, TestStartupConfigurationService<[EF_DB_CONTEXT]>>(
130+
Path.Combine(System.AppContext.BaseDirectory, @"[PATH_TO_WEB_APP]"));
131+
132+
var response = testEnvironment.Client.GetAsync("/api/data").Result;
133+
response.EnsureSuccessStatusCode();
125134

126-
// Test result content
127-
var result = JsonConvert.DeserializeObject<Data[]>(response.Content.ReadAsStringAsync().Result);
135+
// Test result content
136+
var result = JsonConvert.DeserializeObject<Data[]>(response.Content.ReadAsStringAsync().Result);
128137

129-
Assert.AreEqual("data", result.Data);
130-
...
138+
Assert.AreEqual("data", result.Data);
139+
}
131140
```
132141

133142
#### MVC Test
@@ -138,9 +147,12 @@ You can access to the this repository using the ASP.NET Core dependency injectio
138147

139148
```csharp
140149
[TestMethod]
141-
public void Mvc_GetBlogsShouldBeOk()
150+
public void ScenarioShouldBeOk()
142151
{
143-
base.TestEnvironment.Client.GetAsync("/").Result.EnsureSuccessStatusCode();
152+
var testEnvironment = new TestEnvironment<Startup, TestStartupConfigurationService<[EF_DB_CONTEXT]>>(
153+
Path.Combine(System.AppContext.BaseDirectory, @"[PATH_TO_WEB_APP]"));
154+
155+
testEnvironment.Client.GetAsync("/").Result.EnsureSuccessStatusCode();
144156

145157
var viewModel = base.TestEnvironment
146158
.ServiceProvider

sample/Sample.Test.Splecflow/Sample.Test.Splecflow.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
<ItemGroup>
1616
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
17-
<PackageReference Include="MSTest.TestAdapter" Version="1.1.14" />
18-
<PackageReference Include="MSTest.TestFramework" Version="1.1.14" />
17+
<PackageReference Include="MSTest.TestAdapter" Version="1.1.17" />
18+
<PackageReference Include="MSTest.TestFramework" Version="1.1.17" />
1919
<PackageReference Include="SpecFlow" Version="2.1.0" />
2020
<PackageReference Include="SpecFlow.NetCore" Version="1.0.0-rc8" />
2121
</ItemGroup>

sample/Sample.Test/Sample.Test.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
<ItemGroup>
1313
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
14-
<PackageReference Include="MSTest.TestAdapter" Version="1.1.14" />
15-
<PackageReference Include="MSTest.TestFramework" Version="1.1.14" />
14+
<PackageReference Include="MSTest.TestAdapter" Version="1.1.17" />
15+
<PackageReference Include="MSTest.TestFramework" Version="1.1.17" />
1616
</ItemGroup>
1717

1818
<ItemGroup>

sample/Sample.Web/Sample.Web.csproj

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
</ItemGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" />
13-
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
14-
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1" />
15-
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.1" />
16-
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.0" />
17-
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" />
18-
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.1.0" />
12+
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.2" />
13+
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.3" />
14+
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.2" />
15+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.2" />
16+
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.1" />
17+
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.2" />
18+
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.1.2" />
1919
</ItemGroup>
2020

2121
<ItemGroup>

src/GeekLearning.Testavior.Configuration/GeekLearning.Testavior.Configuration.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
</PropertyGroup>
1717

1818
<ItemGroup>
19-
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="1.1.1" />
20-
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="1.1.2" />
19+
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="1.1.2" />
20+
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="1.1.3" />
2121
</ItemGroup>
2222

2323
<ItemGroup Condition=" '$(TargetFramework)' == 'net451' ">

src/GeekLearning.Testavior/GeekLearning.Testavior.csproj

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@
2020
</ItemGroup>
2121

2222
<ItemGroup>
23-
<PackageReference Include="Microsoft.AspNetCore.Authentication" Version="1.1.1" />
24-
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="1.1.1" />
25-
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="1.1.1" />
26-
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="1.1.2" />
27-
<PackageReference Include="Microsoft.AspNetCore.Mvc.ViewFeatures" Version="1.1.2" />
28-
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="1.1.1" />
29-
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="1.1.1" />
30-
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="1.1.1" />
31-
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="1.1.0" />
32-
<PackageReference Include="Microsoft.Extensions.Options" Version="1.1.1" />
23+
<PackageReference Include="Microsoft.AspNetCore.Authentication" Version="1.1.2" />
24+
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="1.1.2" />
25+
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="1.1.2" />
26+
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="1.1.3" />
27+
<PackageReference Include="Microsoft.AspNetCore.Mvc.ViewFeatures" Version="1.1.3" />
28+
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="1.1.2" />
29+
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="1.1.2" />
30+
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="1.1.2" />
31+
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="1.1.1" />
32+
<PackageReference Include="Microsoft.Extensions.Options" Version="1.1.2" />
3333
</ItemGroup>
3434

3535
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.6' ">

0 commit comments

Comments
 (0)