Skip to content

Commit

Permalink
Merge pull request akkadotnet#1659 from Silv3rcircl3/NUnit3_support
Browse files Browse the repository at this point in the history
Support for NUnit 3
  • Loading branch information
rogeralsing committed Jan 24, 2016
2 parents b459669 + fe9605f commit 20e5ffe
Show file tree
Hide file tree
Showing 16 changed files with 604 additions and 5 deletions.
3 changes: 2 additions & 1 deletion build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ pushd %~dp0

src\.nuget\NuGet.exe update -self

src\.nuget\NuGet.exe install FAKE -ConfigFile src\.nuget\Nuget.Config -OutputDirectory src\packages -ExcludeVersion -Version 4.1.0
src\.nuget\NuGet.exe install FAKE -ConfigFile src\.nuget\Nuget.Config -OutputDirectory src\packages -ExcludeVersion -Version 4.16.1

src\.nuget\NuGet.exe install xunit.runner.console -ConfigFile src\.nuget\Nuget.Config -OutputDirectory src\packages\FAKE -ExcludeVersion -Version 2.0.0
src\.nuget\NuGet.exe install nunit.runners -ConfigFile src\.nuget\Nuget.Config -OutputDirectory src\packages\FAKE -ExcludeVersion -Version 2.6.4
src\.nuget\NuGet.exe install NUnit.Console -ConfigFile src\.nuget\Nuget.Config -OutputDirectory src\packages\FAKE -ExcludeVersion -Version 3.0.0
src\.nuget\NuGet.exe install NBench.Runner -OutputDirectory src\packages -ExcludeVersion

if not exist src\packages\SourceLink.Fake\tools\SourceLink.fsx (
Expand Down
11 changes: 10 additions & 1 deletion build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ Target "CopyOutput" <| fun _ ->
"contrib/dependencyinjection/Akka.DI.TestKit"
"contrib/testkits/Akka.TestKit.Xunit"
"contrib/testkits/Akka.TestKit.NUnit"
"contrib/testkits/Akka.TestKit.NUnit3"
"contrib/testkits/Akka.TestKit.Xunit2"
"contrib/serializers/Akka.Serialization.Wire"
"contrib/cluster/Akka.Cluster.Tools"
Expand Down Expand Up @@ -223,9 +224,11 @@ open Fake.Testing
Target "RunTests" <| fun _ ->
let msTestAssemblies = !! "src/**/bin/Release/Akka.TestKit.VsTest.Tests.dll"
let nunitTestAssemblies = !! "src/**/bin/Release/Akka.TestKit.NUnit.Tests.dll"
let nunit3TestAssemblies = !! "src/**/bin/Release/Akka.TestKit.NUnit3.Tests.dll"
let xunitTestAssemblies = !! "src/**/bin/Release/*.Tests.dll" --
"src/**/bin/Release/Akka.TestKit.VsTest.Tests.dll" --
"src/**/bin/Release/Akka.TestKit.NUnit.Tests.dll"
"src/**/bin/Release/Akka.TestKit.NUnit.Tests.dll" --
"src/**/bin/Release/Akka.TestKit.NUnit3.Tests.dll"

mkdir testOutput

Expand All @@ -236,6 +239,12 @@ Target "RunTests" <| fun _ ->
DisableShadowCopy = true;
OutputFile = testOutput + @"\NUnitTestResults.xml"})

nunit3TestAssemblies
|> NUnit3 (fun p ->
{p with
ShadowCopy = false;
ResultSpecs = [(testOutput + @"\NUnit3TestResults.xml")]})

let xunitToolPath = findToolInSubPath "xunit.console.exe" "src/packages/xunit.runner.console*/tools"
printfn "Using XUnit runner: %s" xunitToolPath
xUnit2
Expand Down
24 changes: 22 additions & 2 deletions src/Akka.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.40629.0
# Visual Studio 14
VisualStudioVersion = 14.0.24720.0
MinimumVisualStudioVersion = 10.0.40219.1
Expand Down Expand Up @@ -263,6 +261,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Akka.Logger.CommonLogging",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Akka.API.Tests", "core\Akka.API.Tests\Akka.API.Tests.csproj", "{F72BE71A-2BE3-413D-A3D9-C7FDBB4E5F08}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Akka.TestKit.NUnit3", "contrib\testkits\Akka.TestKit.NUnit3\Akka.TestKit.NUnit3.csproj", "{62A7BBA3-2AA6-4F9B-8ACA-15C3863C026E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Akka.TestKit.NUnit3.Tests", "contrib\testkits\Akka.TestKit.NUnit3.Tests\Akka.TestKit.NUnit3.Tests.csproj", "{FF91B397-1E60-4B94-99A1-B534C7BB91A5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug Mono|Any CPU = Debug Mono|Any CPU
Expand Down Expand Up @@ -980,6 +982,22 @@ Global
{F72BE71A-2BE3-413D-A3D9-C7FDBB4E5F08}.Release Mono|Any CPU.Build.0 = Release Mono|Any CPU
{F72BE71A-2BE3-413D-A3D9-C7FDBB4E5F08}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F72BE71A-2BE3-413D-A3D9-C7FDBB4E5F08}.Release|Any CPU.Build.0 = Release|Any CPU
{62A7BBA3-2AA6-4F9B-8ACA-15C3863C026E}.Debug Mono|Any CPU.ActiveCfg = Debug|Any CPU
{62A7BBA3-2AA6-4F9B-8ACA-15C3863C026E}.Debug Mono|Any CPU.Build.0 = Debug|Any CPU
{62A7BBA3-2AA6-4F9B-8ACA-15C3863C026E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{62A7BBA3-2AA6-4F9B-8ACA-15C3863C026E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{62A7BBA3-2AA6-4F9B-8ACA-15C3863C026E}.Release Mono|Any CPU.ActiveCfg = Release|Any CPU
{62A7BBA3-2AA6-4F9B-8ACA-15C3863C026E}.Release Mono|Any CPU.Build.0 = Release|Any CPU
{62A7BBA3-2AA6-4F9B-8ACA-15C3863C026E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{62A7BBA3-2AA6-4F9B-8ACA-15C3863C026E}.Release|Any CPU.Build.0 = Release|Any CPU
{FF91B397-1E60-4B94-99A1-B534C7BB91A5}.Debug Mono|Any CPU.ActiveCfg = Debug|Any CPU
{FF91B397-1E60-4B94-99A1-B534C7BB91A5}.Debug Mono|Any CPU.Build.0 = Debug|Any CPU
{FF91B397-1E60-4B94-99A1-B534C7BB91A5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FF91B397-1E60-4B94-99A1-B534C7BB91A5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FF91B397-1E60-4B94-99A1-B534C7BB91A5}.Release Mono|Any CPU.ActiveCfg = Release|Any CPU
{FF91B397-1E60-4B94-99A1-B534C7BB91A5}.Release Mono|Any CPU.Build.0 = Release|Any CPU
{FF91B397-1E60-4B94-99A1-B534C7BB91A5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FF91B397-1E60-4B94-99A1-B534C7BB91A5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -1097,5 +1115,7 @@ Global
{453DD4B1-64B8-4B50-BFDA-3489E32D30D8} = {01167D3C-49C4-4CDE-9787-C176D139ACDD}
{C84A7909-72A7-4164-B348-8D3E9D16F5A4} = {FFEC736B-EDA3-433C-8564-7C14676601A1}
{F72BE71A-2BE3-413D-A3D9-C7FDBB4E5F08} = {01167D3C-49C4-4CDE-9787-C176D139ACDD}
{62A7BBA3-2AA6-4F9B-8ACA-15C3863C026E} = {7625FD95-4B2C-4A5B-BDD5-94B1493FAC8E}
{FF91B397-1E60-4B94-99A1-B534C7BB91A5} = {7625FD95-4B2C-4A5B-BDD5-94B1493FAC8E}
EndGlobalSection
EndGlobal
2 changes: 1 addition & 1 deletion src/contrib/testkits/Akka.TestKit.NUnit/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NUnit" version="2.6.4" targetFramework="net45" />
<package id="NUnit" version="2.6.4" targetFramework="net45" allowedVersions="(,3.0.0)"/>
</packages>
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{FF91B397-1E60-4B94-99A1-B534C7BB91A5}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Akka.TestKit.NUnit3.Tests</RootNamespace>
<AssemblyName>Akka.TestKit.NUnit3.Tests</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="nunit.framework, Version=3.0.5797.27534, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\NUnit.3.0.0\lib\net45\nunit.framework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AssertionsTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TestKitTestFixtureTest.cs" />
<Compile Include="TestKitTests.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\core\Akka.TestKit\Akka.TestKit.csproj">
<Project>{0d3cbad0-bbdb-43e5-afc4-ed1d3ecdc224}</Project>
<Name>Akka.TestKit</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\core\Akka\Akka.csproj">
<Project>{5deddf90-37f0-48d3-a0b0-a5cbd8a7e377}</Project>
<Name>Akka</Name>
</ProjectReference>
<ProjectReference Include="..\Akka.TestKit.NUnit3\Akka.TestKit.NUnit3.csproj">
<Project>{62a7bba3-2aa6-4f9b-8aca-15c3863c026e}</Project>
<Name>Akka.TestKit.NUnit3</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
78 changes: 78 additions & 0 deletions src/contrib/testkits/Akka.TestKit.NUnit3.Tests/AssertionsTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
//-----------------------------------------------------------------------
// <copyright file="AssertionsTests.cs" company="Akka.NET Project">
// Copyright (C) 2009-2016 Typesafe Inc. <http://www.typesafe.com>
// Copyright (C) 2013-2016 Akka.NET project <https://github.com/akkadotnet/akka.net>
// </copyright>
//----------------------------------------------------------------------

using NUnit.Framework;

namespace Akka.TestKit.NUnit3.Tests
{
[TestFixture]
public class AssertionsTests
{
private readonly NUnitAssertions _assertions;

public AssertionsTests()
{
_assertions = new NUnitAssertions();
}

[Test]
public void Fail_should_throw()
{
Assert.Throws<AssertionException>(() => _assertions.Fail());
}

[Test]
public void AssertTrue_should_throw_on_false()
{
Assert.Throws<AssertionException>(() => _assertions.AssertTrue(false));
}

[Test]
public void AssertTrue_should_succeed_on_true()
{
_assertions.AssertTrue(true);
}

[Test]
public void AssertFalse_should_throw_on_true()
{
Assert.Throws<AssertionException>(() => _assertions.AssertFalse(true));
}

[Test]
public void AssertFalse_should_succeed_on_false()
{
_assertions.AssertFalse(false);
}


[Test]
public void AssertEqual_should_throw_on_not_equal()
{
Assert.Throws<AssertionException>(() => _assertions.AssertEqual(42, 4711));
}

[Test]
public void AssertEqual_should_succeed_on_equal()
{
_assertions.AssertEqual(42, 42);
}


[Test]
public void AssertEqualWithComparer_should_throw_on_not_equal()
{
Assert.Throws<AssertionException>(() => _assertions.AssertEqual(42, 42, (x, y) => false));
}

[Test]
public void AssertEqualWithComparer_should_succeed_on_equal()
{
_assertions.AssertEqual(42, 4711, (x, y) => true);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// Allgemeine Informationen über eine Assembly werden über die folgenden
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
// die einer Assembly zugeordnet sind.
[assembly: AssemblyTitle("Akka.TestKit.NUnit3.Tests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Akka.TestKit.NUnit3.Tests")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von
// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
[assembly: ComVisible(false)]

// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
[assembly: Guid("ff91b397-1e60-4b94-99a1-b534c7bb91a5")]

// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
//
// Hauptversion
// Nebenversion
// Buildnummer
// Revision
//
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//-----------------------------------------------------------------------
// <copyright file="TestKitTestFixtureTest.cs" company="Akka.NET Project">
// Copyright (C) 2009-2016 Typesafe Inc. <http://www.typesafe.com>
// Copyright (C) 2013-2016 Akka.NET project <https://github.com/akkadotnet/akka.net>
// </copyright>
//----------------------------------------------------------------------

using Akka.Actor;
using Akka.TestKit.TestActors;
using NUnit.Framework;

namespace Akka.TestKit.NUnit3.Tests
{
[TestFixture]
public class TestKitTestFixtureTest : TestKit
{
[Test]
public void Can_create_more_than_one_test_in_a_fixture_with_the_same_actor_name_test1()
{
Sys.ActorOf<BlackHoleActor>("actor-name");
}

[Test]
public void Can_create_more_than_one_test_in_a_fixture_with_the_same_actor_name_test2()
{
Sys.ActorOf<BlackHoleActor>("actor-name");
}
}
}
29 changes: 29 additions & 0 deletions src/contrib/testkits/Akka.TestKit.NUnit3.Tests/TestKitTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//-----------------------------------------------------------------------
// <copyright file="TestKitTests.cs" company="Akka.NET Project">
// Copyright (C) 2009-2016 Typesafe Inc. <http://www.typesafe.com>
// Copyright (C) 2013-2016 Akka.NET project <https://github.com/akkadotnet/akka.net>
// </copyright>
//----------------------------------------------------------------------

using Akka.Actor;
using NUnit.Framework;

namespace Akka.TestKit.NUnit3.Tests
{
[TestFixture]
public class TestKitTests : TestKit
{
[TearDown]
public void Cleanup()
{
Shutdown();
}

[Test]
public void Expect_a_message()
{
TestActor.Tell("Test");
ExpectMsg("Test");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NUnit" version="3.0.0" targetFramework="net452" />
</packages>
Loading

0 comments on commit 20e5ffe

Please sign in to comment.