-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new helper test method for XUnit (#233)
* Added new helper test method * moved to it's own file
- Loading branch information
1 parent
ec5aee8
commit 1e5faf3
Showing
8 changed files
with
81 additions
and
441 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/Testing.XUnit/Rocket.Surgery.Extensions.Testing.XUnit.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<IsTestProject>false</IsTestProject> | ||
<RootNamespace>Rocket.Surgery.Extensions.Testing</RootNamespace> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="xunit.abstractions" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System.Reflection; | ||
using Xunit.Abstractions; | ||
|
||
// ReSharper disable once CheckNamespace | ||
namespace xunit | ||
{ | ||
/// <summary> | ||
/// Helpful XUnit Extensions | ||
/// </summary> | ||
public static class XUnitExtensions | ||
{ | ||
/// <summary> | ||
/// Gets the test from the ITestOutputHelper | ||
/// </summary> | ||
/// <param name="output"></param> | ||
/// <returns></returns> | ||
public static ITest GetTest(this ITestOutputHelper output) | ||
{ | ||
var type = output.GetType(); | ||
var testMember = type.GetField("test", BindingFlags.Instance | BindingFlags.NonPublic); | ||
return (ITest)testMember.GetValue(output); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using FluentAssertions; | ||
using xunit; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace Rocket.Surgery.Extensions.Testing.Tests | ||
{ | ||
public class XUnitExtensionsTests : LoggerTest | ||
{ | ||
private readonly ITestOutputHelper _outputHelper; | ||
|
||
public XUnitExtensionsTests(ITestOutputHelper outputHelper) : base(outputHelper) | ||
{ | ||
_outputHelper = outputHelper; | ||
} | ||
|
||
[Fact] | ||
public void GetTestTest() | ||
{ | ||
var test = _outputHelper.GetTest(); | ||
test.Should().NotBeNull(); | ||
test.DisplayName.Should().Be("Rocket.Surgery.Extensions.Testing.Tests.XUnitExtensionsTests.GetTestTest"); | ||
} | ||
} | ||
} |