4

Visual Studio 2012 プロジェクトと次の NuGet パッケージがインストールされています。

  • Moqを使用した自動モッキングによるAutoFixture
  • xUnit.net データ理論による Autofixture
  • AutoFixture
  • モク
  • xUnit.net: 拡張機能
  • xUnit.net: ランナー
  • xUnit.net

次の不自然な Logger クラス (Logger.fs) があるとします。

namespace FUnit

type public ILoggerContext =
    abstract member LogPath :string

type public LoggerContext (logPath :string) =
    member val LogPath = logPath with get, set

    interface ILoggerContext with
        member this.LogPath = this.LogPath

type public Logger () =
    member this.Log (context: ILoggerContext) value =
        System.String.Format("Logged {0} to {1}.", value, context.LogPath)

および次の単体テスト:

namespace FUnit.Test

open FUnit

type public Math_Add() = 

    [<Xunit.Extensions.Theory>]
    [<Ploeh.AutoFixture.Xunit.AutoData>]
    member this.``Should Output Value And Path`` (path :string) =
        let context = new LoggerContext(path)
        let logger = new Logger()

        let expected = System.String.Format("Logged value to {0}.", path)
        let actual = logger.Log context "value"

        Xunit.Assert.Equal<string>(expected, actual)

テスト エクスプローラーは、すべてのテストを表示してプロジェクトをビルドしていることを確認した後、単体テストを認識しません。プロジェクトは正しくビルドされ、ビルド、一般、またはテストの出力ログにエラーや警告はありません。

現在の Theory 属性と AutoData 属性を Fact 属性に置き換えると、テストが表示されます。

AutoFixture は F# テスト プロジェクトでサポートされていますか? 他の誰かがこれを複製して、私が間違っていることを知ることができますか?

4

1 に答える 1