XUnit测试不在解决方案中运行

时间:2019-10-21 06:52:55

标签: c# visual-studio-2017 xunit.net .net-core-2.2

我无法在解决方案中运行任何xunit测试。 Visual Studio测试资源管理器找到了它们,但似乎跑步者找不到任何东西。

规格:

  • Visual Studio 2017 15.9.13
  • .NET Core 2.2

该问题专门针对XUnit测试项目,因为NUnit和MsTest项目正常运行测试。 XUnit项目中的所有软件包都是最新的(撰写本文时):

  • Microsoft.NETCore.App 2.2.0
  • Microsoft.NET.Test.Sdk 16.3.0
  • xunit 2.4.1
  • xunit.runner.visualstudio 2.4.1

此外,问题仅在于此解决方案,因为在新的解决方案中,xunit测试可以正常运行。

我具有测试的诊断日志级别,并且看到的内容是它找不到任何测试。

此:

Test framework could not be determined for project: C:\path\to\my\project\XUnitTestProject1\bin\Debug\netcoreapp2.2\XUnitTestProject1.dll because reference path is null for at least one reference: Microsoft.NETCore.App

这:

No test is available in C:\path\to\my\project\XUnitTestProject1\bin\Debug\netcoreapp2.2\XUnitTestProject1.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.

我的考试班

using Xunit;

namespace XUnitTestProject1
{
    public class MyTestClass
    {
        [Fact]
        public void some_tests()
        {
            Assert.True(true);
        }
    }
}

完整的日志输出面板

[10/21/2019 10:17:39 AM Diagnostic] About to Enqueue operation 'RunSelectedOperation', hashcode:37960157 
[10/21/2019 10:17:39 AM Diagnostic] Enqueue operation 'RunSelectedOperation', hashcode:37960157 
[10/21/2019 10:17:39 AM Diagnostic] Operation left in the the queue: 1
[10/21/2019 10:17:39 AM Diagnostic]     'RunSelectedOperation', hashcode:37960157
[10/21/2019 10:17:39 AM Diagnostic] 

[10/21/2019 10:17:39 AM Diagnostic] Processing Queue .....
[10/21/2019 10:17:39 AM Diagnostic] Operation Dequeue : 'RunSelectedOperation'
[10/21/2019 10:17:39 AM Diagnostic] VirtualReadOnlyTestDataStore.OperationStateChanged State=OperationSetStarted, operationInProgress=False
[10/21/2019 10:17:39 AM Diagnostic] TestDiscoveryStats.OperationStateChanged State=OperationSetStarted, InProgress=False
[10/21/2019 10:17:39 AM Diagnostic] VirtualReadOnlyTestDataStore.OperationStateChanged State=ChangeDetectionStarting, operationInProgress=True
[10/21/2019 10:17:39 AM Diagnostic] TestDiscoveryStats.OperationStateChanged State=ChangeDetectionStarting, InProgress=False
[10/21/2019 10:17:39 AM Diagnostic] We programmatically start the build in TestWindowHost.UpdateContainer... 
[10/21/2019 10:17:39 AM Diagnostic] After we await the build that programmatically started in TestWindowHost.UpdateContainer... 
[10/21/2019 10:17:39 AM Diagnostic] TestContainer update (build) complete : 405 ms
[10/21/2019 10:17:39 AM Diagnostic] Time taken for fetching Roslyn supported projects: 0 milliseconds.
[10/21/2019 10:17:39 AM Diagnostic] DiscoveryOperation<RunSelectedOperation> FinishedChangedCotainers, changed container count is 0
[10/21/2019 10:17:39 AM Diagnostic] VirtualReadOnlyTestDataStore.OperationStateChanged State=ChangeDetectionFinished, operationInProgress=False
[10/21/2019 10:17:39 AM Diagnostic] Test framework could not be determined for project: C:\path\to\my\project\XUnitTestProject1\bin\Debug\netcoreapp2.2\XUnitTestProject1.dll because reference path is null for at least one reference: Microsoft.NETCore.App
[10/21/2019 10:17:39 AM Diagnostic] TestDiscoveryStats.OperationStateChanged State=ChangeDetectionFinished, InProgress=False
[10/21/2019 10:17:39 AM Diagnostic] VirtualReadOnlyTestDataStore.OperationStateChanged State=TestExecutionStarting, operationInProgress=False
[10/21/2019 10:17:39 AM Diagnostic] TestDiscoveryStats.OperationStateChanged State=TestExecutionStarting, InProgress=False
[10/21/2019 10:17:39 AM Diagnostic] VirtualReadOnlyTestDataStore.OperationStateChanged State=TestExecutionStarted, operationInProgress=False
[10/21/2019 10:17:39 AM Informational] ------ Run test started ------
[10/21/2019 10:17:39 AM Diagnostic] TestDiscoveryStats.OperationStateChanged State=TestExecutionStarted, InProgress=False
[10/21/2019 10:17:39 AM Diagnostic] RunSettings Content:
<RunSettings>
  <RunConfiguration>
    <ResultsDirectory>C:\path\to\my\project\TestResults</ResultsDirectory>
    <SolutionDirectory>C:\path\to\my\project\</SolutionDirectory>
    <TargetPlatform>X64</TargetPlatform>
    <TargetFrameworkVersion>Framework45</TargetFrameworkVersion>
  </RunConfiguration>
</RunSettings>
[10/21/2019 10:17:39 AM Diagnostic] Value of UseSpecifiedAdapterLocations as specified in Tools -> Options: True
[10/21/2019 10:17:39 AM Diagnostic] Value of FallbackToGlobalVsix as specified in Tools -> Options: True
[10/21/2019 10:17:39 AM Diagnostic] Adapter location settings being used after evaluation: UseSpecifiedAdapterLocations = False, SkipDefaultAdapters = False, AreAllTestContainersCSharpOrVBProjectsOnly = True
[10/21/2019 10:17:39 AM Diagnostic] Final RunSettings for the current TestRunCriteria:
<RunSettings>
  <RunConfiguration>
    <ResultsDirectory>C:\path\to\my\project\TestResults</ResultsDirectory>
    <SolutionDirectory>C:\path\to\my\project\</SolutionDirectory>
    <TargetPlatform>X64</TargetPlatform>
    <TargetFrameworkVersion>FrameworkCore10</TargetFrameworkVersion>
    <CollectSourceInformation>False</CollectSourceInformation>
  </RunConfiguration>
</RunSettings>
[10/21/2019 10:17:40 AM Warning] No test is available in C:\path\to\my\project\XUnitTestProject1\bin\Debug\netcoreapp2.2\XUnitTestProject1.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.
[10/21/2019 10:17:40 AM Diagnostic] VirtualReadOnlyTestDataStore.OperationStateChanged State=OperationSetFinished, operationInProgress=False
[10/21/2019 10:17:40 AM Diagnostic] TestDiscoveryStats.OperationStateChanged State=OperationSetFinished, InProgress=False
[10/21/2019 10:17:40 AM Diagnostic] ***    Run finished using 'InMemoryUnitTestWriter' ***
[10/21/2019 10:17:40 AM Informational] ========== Run test finished: 0 run (0:00:00.7402273) ==========
[10/21/2019 10:17:40 AM Diagnostic] VirtualReadOnlyTestDataStore.OperationStateChanged State=TestExecutionFinished, operationInProgress=False
[10/21/2019 10:17:40 AM Diagnostic] TestDiscoveryStats.OperationStateChanged State=TestExecutionFinished, InProgress=False

0 个答案:

没有答案