2016-11-28 16 views
2

XunitとFluent Assertionsを使用してコードカバレッジをASP.NET Core上で実行しようとしています。しかし、私は本当に理解していないエラーメッセージが表示されています。OpenCoverでXUnitとFluentAssertionsを実行するとエラーメッセージが表示される

テストプロジェクトのマイproject.json:

{ 
    "version": "1.0.0-*", 
    "testRunner": "xunit", 
    "debugType": "portable", 
    "dependencies": { 
    "xunit": "2.2.0-beta2-build3300", 
    "FluentAssertions": "4.15.0", 
    "dotnet-test-xunit": "2.2.0-preview2-build1029", 
    "ExpenseReporting": "1.0.0-*", 
    "Moq": "4.6.38-alpha" 
    }, 
    "commands": { 
    "test": "xunit.runner.dnx" 
    }, 
    "frameworks": { 
    "netcoreapp1.0": { 
     "dependencies": { 
     "Microsoft.NETCore.App": { 
      "type": "platform", 
      "version": "1.0.1" 
     } 
     } 
    } 
    } 
} 

OpenCoverのための私のコマンド:

OpenCover.Console.exe -target:"C:\Program Files\dotnet\dotnet.exe" -targetargs:"test "C:\Users\johndoe\Desktop\Application\ExpenseReporting.Test\project.json"" -output:coverage.xml -register:user -filter:"+[*]* -[xunit*]* -[*]*Migrations.*" 

は、私は、エラーの多くを受けるが、すべては、この種のものであり:

An System.IO.DirectoryNotFoundException occured: Could not find a part of the path 'C:\projects\fluentassertions-vf06b\Src\FluentAssertions.NET40\Execution\MSTestFramwork.cs'. 

ディレクトリが存在しないため、ディレクトリが見つからないことは明らかです。なぜそれがそこにアクセスしようとしているのだろうか?

+0

あなたはこれを任意の解決策を見つけたことがありますか? – valorl

答えて

0

project.jsonファイルに問題があるようです。 dotnetコマンドを使用している場合は、commands要素はありません。あなたのproject.jsonファイルは、このようなものでなければなりません。ここで

{ 
    "version": "1.0.0-*", 
    "testRunner": "xunit", 
    "dependencies": { 
     "xunit": "2.2.0-beta2-build3300", 
     "dotnet-test-xunit": "2.2.0-preview2-build1029", 
     "FluentAssertions": "4.15.0", 
     "ExpenseReporting": "1.0.0-*", 
     "Moq": "4.6.38-alpha" 
    }, 
    "frameworks": { 
     "netcoreapp1.0": { 
      "dependencies": { 
       "Microsoft.NETCore.App": { 
        "type": "platform", 
        "version": "1.0.0" 
       } 
      } 
     } 
    } 
} 

https://xunit.github.io/docs/getting-started-dotnet-core.html

テストを実行し、オープンカバーを使用してコードカバレッジを取得するコマンドです。

OpenCover.Console.exe -target:"C:\Program Files\dotnet\dotnet.exe" -targetargs:"test C:\projects\HelloWorld.Tests" -register:user -filter:"+[*]* -[xunit*]*" -output:coverage.xml -oldStyle

+1

FluentAssertionsでも同じエラーが表示される – Stefan

2

OpenCoverは、そのカバレッジレポートにFluentAssertionsのソースコードが含まれるようにしようとしているように見えます。私はなぜこれをやっているのか完全にはわかっていませんが、FluentAssertionsを除外するようにOpenCoverに指示することでこれを回避することができました。

これは私が使用しているフィルターです:

-filter:"+[*]* -[*FluentAssertions*]*" 
+0

興味深いですが、少なくともフィルタを追加すると、エラーメッセージが表示されなくなります。複数のフィルタの参照と使用:https://github.com/opencover/opencover/wiki/Usage#understanding-filters – ICantSeeSharp

関連する問題