2013-02-12 3 views
7

編集:これをVS 2010で試したところ、問題は発生しませんでした。この問題はVS 2012でのみ発生します。これは本当にバグでしょうか?これは私の2つの別々のラップトップでも、友人のノートパソコン(最新のコードを入手したばかり)でさえも起こっています。VS 2012で最新のチェックインコードをスキップする - VS 2010で動作する

まず、問題のスクリーンショットを示します。このメソッドはすべて新しいコードです。

enter image description here

デバッガが私の最近のチェックインからのコードを飛ばしています。コメントは、以下のコードで、このメソッドをデバッグするときに何が起こっているのかを説明しています。したがって、実際にコードを試して理解する必要はありません。コード行がスキップされていることに気付くだけです。コードがデバッグ対象のアセンブリと一致しないと思っている場合は、私にご負担ください。デバッガが新しいコードを認識する場所は表示されますが、既存のコードは認識されません。そして、この動作は、ディスク上のコードを削除し、最新のものをもう一度入手した後、2つの異なるラップトップで発生しています。各コメントは、デバッガが行をヒットするかどうかを示します。

[TestMethod()] 
[DeploymentItem("PrestoCommon.dll")] 
public void ApplicationShouldBeInstalledTest_UseCase9() 
{ 
    // Debugger hits this line 
    ApplicationServer appServerAccessor = new ApplicationServer(); 

    // Debugger does not hit these next two lines 
    PrivateObject privateObject = new PrivateObject(appServerAccessor); 
    ApplicationServer appServer = ApplicationServerLogic.GetByName("server10"); 

    // Debugger hits this line. Weirdness: both objects are null, and after this line runs, 
    // appServerAccessor is no longer null. 
    appServerAccessor.Id = appServer.Id; 

    // Skips this line 
    ApplicationWithOverrideVariableGroup appWithValidGroup = appServer.ApplicationsWithOverrideGroup[0]; 

    // Debugger hits this line, but F11 doesn't take me into the method. 
    appWithValidGroup.CustomVariableGroup = CustomVariableGroupLogic.GetById("CustomVariableGroups/4"); 

    // Skips this line 
    Assert.AreEqual(true, true); 
} 

逆アセンブリでは、実際にヒットしたコード行のみが表示されます。今

enter image description here

、これをチェックしてください。私は新しいコード行を追加すると、デバッガがそれを認識し、デバッガによって認識される限り、他のコード行が変更されます。メソッド内の2行目のコードだけが新しいものです。これが起こってすることができますどのように

enter image description here

[TestMethod()] 
[DeploymentItem("PrestoCommon.dll")] 
public void ApplicationShouldBeInstalledTest_UseCase9() 
{ 
    // Debugger hits this line 
    ApplicationServer appServerAccessor = new ApplicationServer(); 

    // New line. It's recognized by the debugger, and it shows up in the disassembly. 
    if (DateTime.Now > DateTime.Now.AddHours(1)) { return; } 

    // Debugger does not hit these next two lines 
    PrivateObject privateObject = new PrivateObject(appServerAccessor); 
    ApplicationServer appServer = ApplicationServerLogic.GetByName("server10"); // Gets hit now. 

    // Debugger hits this line. Weirdness: both objects are null, and after this line runs, 
    // appServerAccessor is no longer null. 
    appServerAccessor.Id = appServer.Id; // No longer gets hit. 

    // Skips this line (now it's getting hit) 
    ApplicationWithOverrideVariableGroup appWithValidGroup = appServer.ApplicationsWithOverrideGroup[0]; 

    // Debugger hits this line, but F11 doesn't take me into the method. Now this gets skipped. 
    appWithValidGroup.CustomVariableGroup = CustomVariableGroupLogic.GetById("CustomVariableGroups/4"); 

    // Skips this line. Still skipped. 
    Assert.AreEqual(true, true); 
} 

そしてここでは、コードの新しい行を示す、解体の部分スナップショットですか?

一点で、すごみに追加すると、このさえ返さ:私が試した

if (DateTime.Now > DateTime.Now.AddDays(1)) { return; } 

もの:
- 2012
VSを修復 - ハードドライブからソースコードを削除し、強制的に最新の
取得 - いくつかのVS clean-up
います - 再起動
- - その他(覚えていないアル利用VS 2010を、変更コードは、チェックイン、VS 2012
で最新の情報を取得しますこれらのうちの1つ)

+0

あなたはおそらく 'ForceInstallation'クラスを表示できますか? – MethodMan

+3

コードを再構築します。また、タスクマネージャでテストランナープロセスを探して停止します。古いバージョンのコードが含まれている可能性があります。 –

+0

私は解決策を閉じ、再オープンし、再構築しました。同じ問題。かなりの数のMsBuildプロセスが実行されているようです。私は再起動して再試行します。私は 'ForceInstallation'クラスを投稿しますが、それはそれだとは思いません。 –

答えて

4

これは単体テスト固有のようです。 VS 2012年:

  • テスト>テスト設定
  • を開き、選択したテストの設定が
  • データと診断ファイル>
  • は、

注意を適用するコードカバレッジ(のVisual Studio 2010)の選択を解除私はソースコードにアクセスできるという利点があり、Presto(http://presto.codeplex.com/)をダウンロードしました。

+1

それはうまくいった!これは、[テスト] - > [テスト設定]でファイルの選択を単に解除することによっても機能します。 –

関連する問題