Skip to content

Instantly share code, notes, and snippets.

@natemcmaster
Created February 4, 2016 22:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save natemcmaster/373d69057075589c979c to your computer and use it in GitHub Desktop.
Save natemcmaster/373d69057075589c979c to your computer and use it in GitHub Desktop.
using System;
using Xunit;
using Xunit.Sdk;
namespace XunitTest
{
[AttributeUsage(AttributeTargets.Method)]
[XunitTestCaseDiscoverer("XunitTest.Discoverer", "XunitTest")]
public class CustomFactAttribute : FactAttribute
{
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xunit.Abstractions;
using Xunit.Sdk;
namespace XunitTest
{
public class Discoverer : IXunitTestCaseDiscoverer
{
private IMessageSink messageSink;
public Discoverer(IMessageSink messageSink)
{
this.messageSink = messageSink;
}
public IEnumerable<IXunitTestCase> Discover(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod,
IAttributeInfo factAttribute)
{
return new[] { new XunitTestCase(messageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod) };
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="xunit" version="2.2.0-beta1-build3239" targetFramework="portable45-net45+win8+wpa81" />
<package id="xunit.abstractions" version="2.0.0" targetFramework="portable45-net45+win8+wpa81" />
<package id="xunit.assert" version="2.2.0-beta1-build3239" targetFramework="portable45-net45+win8+wpa81" />
<package id="xunit.core" version="2.2.0-beta1-build3239" targetFramework="portable45-net45+win8+wpa81" />
<package id="xunit.extensibility.core" version="2.2.0-beta1-build3239" targetFramework="portable45-net45+win8+wpa81" />
<package id="xunit.extensibility.execution" version="2.2.0-beta1-build3239" targetFramework="portable45-net45+win8+wpa81" />
<package id="xunit.runner.console" version="2.2.0-beta1-build3239" targetFramework="portable45-net45+win8+wpa81" developmentDependency="true" />
<package id="xunit.runner.visualstudio" version="2.2.0-beta1-build1144" targetFramework="portable45-net45+win8+wpa81" developmentDependency="true" />
</packages>
using Xunit;
namespace XunitTest
{
public class TestClass
{
[CustomFact]
public void Pass()
{
Assert.True(true);
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\xunit.runner.visualstudio.2.2.0-beta1-build1144\build\portable-net45+win8+wp8+wpa81\xunit.runner.visualstudio.props" Condition="Exists('..\packages\xunit.runner.visualstudio.2.2.0-beta1-build1144\build\portable-net45+win8+wp8+wpa81\xunit.runner.visualstudio.props')" />
<Import Project="..\packages\xunit.core.2.2.0-beta1-build3239\build\portable-net45+win8+wp8+wpa81\xunit.core.props" Condition="Exists('..\packages\xunit.core.2.2.0-beta1-build3239\build\portable-net45+win8+wp8+wpa81\xunit.core.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{1726E523-731C-459F-B925-ECF39178E251}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>XunitTest</RootNamespace>
<AssemblyName>XunitTest</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TargetFrameworkProfile>Profile111</TargetFrameworkProfile>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</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>
<Compile Include="CustomFactAttribute.cs" />
<Compile Include="Discoverer.cs" />
<Compile Include="TestClass.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.abstractions.2.0.0\lib\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.abstractions.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="xunit.assert, Version=2.2.0.3239, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.assert.2.2.0-beta1-build3239\lib\portable-net45+win8+wp8+wpa81\xunit.assert.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="xunit.core, Version=2.2.0.3239, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.extensibility.core.2.2.0-beta1-build3239\lib\portable-net45+win8+wp8+wpa81\xunit.core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="xunit.execution.dotnet, Version=2.2.0.3239, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.extensibility.execution.2.2.0-beta1-build3239\lib\portable-net45+win8+wp8+wpa81\xunit.execution.dotnet.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\xunit.core.2.2.0-beta1-build3239\build\portable-net45+win8+wp8+wpa81\xunit.core.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.core.2.2.0-beta1-build3239\build\portable-net45+win8+wp8+wpa81\xunit.core.props'))" />
<Error Condition="!Exists('..\packages\xunit.runner.visualstudio.2.2.0-beta1-build1144\build\portable-net45+win8+wp8+wpa81\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.runner.visualstudio.2.2.0-beta1-build1144\build\portable-net45+win8+wp8+wpa81\xunit.runner.visualstudio.props'))" />
</Target>
<!-- 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment