Visual Studio单元测试崩溃

时间:2018-01-13 18:08:23

标签: c# visual-studio unit-testing

在visual studio中运行C#程序的单元测试时,我突然出错了。 我想在添加System.Numerics.Vectors NuGet包之后出现错误,我运行的测试还没有使用它。 在添加之前,测试运行很好。 我收到以下错误:

for more details on managing these settings.
[1/13/2018 6:37:32 PM Informational] Test Adapter for Google Test: Test discovery starting...
[1/13/2018 6:37:32 PM Error] ERROR: Exception while discovering tests: System.AggregateException: One or more errors occurred. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at GoogleTestAdapter.DiaResolver.PeParser.<>c__DisplayClass4_0.<ProcessImports>b__0(LoadedImage image)
   at GoogleTestAdapter.DiaResolver.PeParser.ParsePeFile(String executable, ILogger logger, Action`1 action)
   at GoogleTestAdapter.DiaResolver.PeParser.ProcessImports(String executable, ILogger logger, Func`2 predicate)
   at GoogleTestAdapter.DiaResolver.PeParser.FindImport(String executable, String import, StringComparison comparisonType, ILogger logger)
   at GoogleTestAdapter.GoogleTestDiscoverer.IsGoogleTestExecutable(String executable, String customRegex, ILogger logger)
   at GoogleTestAdapter.GoogleTestDiscoverer.<>c__DisplayClass6_0.<DiscoverTests>b__0()
   at GoogleTestAdapter.Settings.SettingsWrapper.ExecuteWithSettingsForExecutable(String executable, Action action, ILogger logger)
   at GoogleTestAdapter.GoogleTestDiscoverer.DiscoverTests(String executable, ITestFrameworkReporter reporter, SettingsWrapper settings, ILogger logger, IDiaResolverFactory diaResolverFactory)
   at GoogleTestAdapter.GoogleTestDiscoverer.<>c__DisplayClass5_0.<DiscoverTests>b__1()
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.WaitAll(Task[] tasks, Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at GoogleTestAdapter.Helpers.Utils.SpawnAndWait(Action[] actions, Int32 timeoutInMs)
   at GoogleTestAdapter.GoogleTestDiscoverer.DiscoverTests(IEnumerable`1 executables, ITestFrameworkReporter reporter)
   at GoogleTestAdapter.TestAdapter.TestDiscoverer.DiscoverTests(IEnumerable`1 executables, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink)
---> (Inner Exception #0) System.NullReferenceException: Object reference not set to an instance of an object.
   at GoogleTestAdapter.DiaResolver.PeParser.<>c__DisplayClass4_0.<ProcessImports>b__0(LoadedImage image)
   at GoogleTestAdapter.DiaResolver.PeParser.ParsePeFile(String executable, ILogger logger, Action`1 action)
   at GoogleTestAdapter.DiaResolver.PeParser.ProcessImports(String executable, ILogger logger, Func`2 predicate)
   at GoogleTestAdapter.DiaResolver.PeParser.FindImport(String executable, String import, StringComparison comparisonType, ILogger logger)
   at GoogleTestAdapter.GoogleTestDiscoverer.IsGoogleTestExecutable(String executable, String customRegex, ILogger logger)
   at GoogleTestAdapter.GoogleTestDiscoverer.<>c__DisplayClass6_0.<DiscoverTests>b__0()
   at GoogleTestAdapter.Settings.SettingsWrapper.ExecuteWithSettingsForExecutable(String executable, Action action, ILogger logger)
   at GoogleTestAdapter.GoogleTestDiscoverer.DiscoverTests(String executable, ITestFrameworkReporter reporter, SettingsWrapper settings, ILogger logger, IDiaResolverFactory diaResolverFactory)
   at GoogleTestAdapter.GoogleTestDiscoverer.<>c__DisplayClass5_0.<DiscoverTests>b__1()
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()<---

有人可以给我建议吗?

要看到它,就足够了:

[TestClass]
public class UnitTest1
{
    [TestMethod]
    public void TestMethod1()
    {

        Console.WriteLine("hello");
    }
}

0 个答案:

没有答案