xUnit2とAutoFixtureを使用してF#で単体テストを作成しようとしていますが、問題が発生しています。私はInlineAutoDataから継承したカスタム属性を持つTheoryを持っており、テストエクスプローラはテストが見つからないと私に言っています。 Theory属性をFact属性で置き換えても、それでも機能しませんが、カスタムInlineData属性を削除するとテストが検出されます。テストはF#で書かれていますが、属性は別のプロジェクトのC#にあります。F#カスタムAutoFixture.InlineAutoDataの理論がテストエクスプローラに表示されない
私は似ているようだが、それは私の問題を解決する助けにはならない。このStackOverflowの質問を発見した:AutoFixture in F# UnitTest Project Not Displaying Unit Tests in Test Explorer
をここでユニットテスト宣言されています
[<Theory>]
[<SyntaxTreeInlineAutoData("Class/SingleClass.cs", 1)>]
[<SyntaxTreeInlineAutoData("Class/MultipleClass.cs", 2)>]
[<SyntaxTreeInlineAutoData("Class/NestedClass.cs", 2)>]
let ``Inspect_WhenVariousContexts_WithSuccess`` (count, tree : SyntaxTree) =
ここでは、宣言を属性:
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
public class SyntaxTreeInlineAutoDataAttribute : InlineAutoDataAttribute
{
#region Constructors
public SyntaxTreeInlineAutoDataAttribute(string sourceFile, params object[] values)
: base(new SyntaxTreeAutoDataAttribute(sourceFile), values)
{
}
#endregion
}
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
public class SyntaxTreeAutoDataAttribute : AutoDataAttribute
{
#region Constructors
public SyntaxTreeAutoDataAttribute() : this(null)
{
}
public SyntaxTreeAutoDataAttribute(string sourceFile)
: base(new Fixture().Customize(new SyntaxTreeCustomization(sourceFile)))
{
}
#endregion
}
[編集]
プロジェクトはC#プロジェクトのポートです。ユニットテストはカスタム属性でうまくいきました。このバグは、F#で書かれたテストでのみ発生しました。
すべてがインストールされています:xUnit2、xUnit.runners.visualstudioおよびAutoFixture。
ありがとうございました。
:私のREPROで
は、私は私のF#プロジェクトに次の
app.config
ファイルを追加することで問題を解決しますか? xUnit Visual Studioランナーをインストールしましたか? –私の[自己回答半関連質問](http://stackoverflow.com/questions/35103781/why-is-the-visual-studio-2015-test-runner-not-discovering-my-xunit-v2-テスト/ 35103782#35103782)はF#、xUnit、VS2015であった(ただし、AutoFixtureではない) –