13

私はMSTestを使用していました

コマンド mstest /testsettings:local.Testsetting /testcontainer:folder\obj\Debug\test.dll を使用します

これが出力です。

実行には次の問題があります: 警告: テスト実行の展開の問題: アセンブリまたはモジュール 'Microsoft.Practices. テスト コンテナ 'test.dll' によって直接的または間接的に参照されている Prism が見つかりませんでした。警告: テスト実行配置の問題: テスト コンテナー 'test.dll' によって直接的または間接的に参照されているアセンブリまたはモジュール 'Project.Common.dll' が見つかりませんでした。警告: テスト実行配置の問題: テスト コンテナー 'test.dll' によって直接的または間接的に参照されているアセンブリまたはモジュール 'Project.Infrastructure.dll' が見つかりませんでした。警告: テスト実行の展開の問題: アセンブリまたはモジュール 'Microsoft.Practices. テスト コンテナ 'test.dll' によって直接的または間接的に参照されている Prism が見つかりませんでした。

MSTest が正常に実行されるようにするにはどうすればよいですか。

4

4 に答える 4

4

PrismファイルをビルドサーバーのGACにインストールできます。

于 2011-03-30T05:58:10.227 に答える
3

テストで直接使用されないすべてのアセンブリは、テスト フォルダーにコピーされません。したがって、これらのテスト メソッドは次のような属性で装飾する必要があります。

[DeploymentItem("Microsoft.Practices.Prism.dll")]

これにより、アセンブリを GAC に追加しなくても問題が解決します。

于 2014-07-29T12:58:21.447 に答える
0

Ok。DeploymentItem は、これを修正する方法です。ただし、DeploymentItem は少し壊れやすいです。

これが私がそれを修正した方法です。

「現在のディレクトリ」は、DeploymentItem と一致する必要があります。私が見つけた最善の妥協点は、現在のディレクトリを .sln ファイルがある場所に設定することです。

これが私のフォルダ構造です。

C:\SomeRootFolder\
C:\SomeRootFolder\MySolution.sln
C:\SomeRootFolder\packages\
C:\SomeRootFolder\packages\MyNugetPackage.1.2.3.4\lib\net45\SomeThirdPartyDll.dll
C:\SomeRootFolder\MyTestProject\MyTestProject.csproj
C:\SomeRootFolder\MyTestProject\MyTestClass.cs

MyTestClass.cs

[TestClass]
public class MyTestClass
{
    [TestMethod]
    /* The DeploymentItem item below is for error ::: Warning: Test Run deployment issue: The assembly or module 'SomeDll' directly or indirectly referenced by the test container 'C:\SomeRootFolder\MyTestProject\bin\debug\MyTestProject.dll' was not found. */
    /* There must be a CD (to the .sln folder) command... before the MsTest.exe command is executed */
    [DeploymentItem(@".\packages\MyNugetPackage.1.2.3.4\lib\net45\SomeDll.dll")]
    public void MyTest()
    {
    }
}

「トリック」は、.sln を格納するフォルダーに CD (ディレクトリの変更) を実行することです。

REM Now the normal restore,build lines
nuget.exe restore "C:\SomeRootFolder\MySolution.sln"
REM the above nuget restore would create "C:\SomeRootFolder\packages\MyNugetPackage.1.2.3.4\lib\net45\SomeThirdPartyDll.dll"
MSBuild.exe "C:\SomeRootFolder\MySolution.sln" /p:Configuration=Debug;FavoriteFood=Popeyes /l:FileLogger,Microsoft.Build.Engine;logfile=MySolution.Debug.Build.log
REM (the below line is the trick to line up the 'current folder' with the relative path of the DeploymentItem)
cd "C:\SomeRootFolder\"
REM now the below will work without the annoying message, note that C:\SomeRootFolder\MyTestProject\bin\Debug\SomeThirdPartyDll.dll exists
MsTest.exe /testcontainer:"C:\SomeRootFolder\MyTestProject\bin\Debug\MyTestProject.dll" /resultsfile:MyTestProject.Dll.Results.trx

「現在のディレクトリ」(CD の結果) は「C:\SomeRootFolder\」にあるため、DeploymentItem の相対パスは正しく機能します。

ジミニー・クリケッツ……それはちょっとおかしな話だ。

ここでポール・テイラーの答えに注意してください

カスタム アセンブリ ベース ディレクトリを使用してコマンド ラインから MsTest を実行する

私にはうまくいきませんでした。

于 2016-04-28T15:00:57.133 に答える