Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Cannot run NUnit tests when datatypes in WPF DotNet Core assemblies are referenced
Magnus
#1 Posted : Thursday, January 9, 2020 4:49:45 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 1/9/2020(UTC)
Posts: 6
Location: Sweden

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
I have a WPF dotnet Core 3.1 project and a separate test project, where I wish to be able to test ViewModels and Converters etc that reference WPF datatypes, such as the IValueConverter interface.

A minimal example is this dummy class in the WPF project:
Code:
 
    public class DummyConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }


with this simple test:
Code:

    [TestFixture]
    public class DummyConverterTests
    {
        [Test]
        public void ConverterTest()
        {
            var converter = new DummyConverter();

            Assert.That(converter, Is.Not.Null);
        }
    }


NCrunch seems to fail already during the exploration phase, marking the test with "Not runnable: Exception occured during exploration". When it anyway finds the test and tries to run it it gets marked as failed with the trace output:
Quote:

System.IO.FileNotFoundException : Could not load file or assembly 'PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
at MyWpfProject.Tests.Converters.DummyConverterTests.ConverterTest()


The test runs fine in Visual Studio 2019 Test Explorer. NCrunch can still run other tests in the test project that doesn't reference wpf.

Here is the project file for the test project:

Code:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <IsPackable>false</IsPackable>
    <RootNamespace>MyWpfProject.Tests</RootNamespace>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="NSubstitute" Version="4.2.1" />
    <PackageReference Include="nunit" Version="3.12.0" />
    <PackageReference Include="NUnit3TestAdapter" Version="3.16.0">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\MySolution\MyWpfProject.csproj" />
  </ItemGroup>
</Project>



I have tried modifying the test project file like this:
Code:

<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <IsPackable>false</IsPackable>
    <RootNamespace>MyWpfProject.Tests</RootNamespace>
    <UseWpf>true</UseWpf>
  </PropertyGroup>
  ...


so the wpf assemblies are referenced, but it doesn't make any difference.
I haven't been able to figure out or find any other way to get the necessary wpf assemblies referenced in dotnet core.

Using NCrunch 4.2.0.7 in Visual Studio 2019 and dotnet core 3.1.

Thanks for any help,
Best regards Magnus

(I have the NCrunch license registered on my work mail but couldn't remember the password and tired of waiting for the reset password mail after 30 minutes...)
michaelkroes
#2 Posted : Thursday, January 9, 2020 7:59:38 PM(UTC)
Rank: NCrunch Developer

Groups: Registered
Joined: 9/22/2017(UTC)
Posts: 213
Location: Netherlands

Thanks: 96 times
Was thanked: 46 time(s) in 44 post(s)
1 user thanked michaelkroes for this useful post.
Magnus on 1/10/2020(UTC)
Magnus
#3 Posted : Friday, January 10, 2020 7:41:58 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 1/9/2020(UTC)
Posts: 6
Location: Sweden

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
I used the NCrunch_VS2019_4.3.0.6.msi and it solved the problem! Thanks!

(The reset password mail was in the spam folder by the way)
1 user thanked Magnus for this useful post.
michaelkroes on 1/10/2020(UTC)
Magnus
#4 Posted : Sunday, January 12, 2020 4:10:49 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 1/9/2020(UTC)
Posts: 6
Location: Sweden

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
Some follow-up information on the 4.3.0.6 in VS2019. Nothing that is really stopping, but that I think you will want to fix.

The exploration phase still seems to have problems, and sometimes I get the "Not runnable: Exception occured during exploration" for the tests in the editor. I haven't been able to figure out a pattern to it.

Also, if I do the "Reload and rebuild selected component" for the test-project in your Tests-dialog, NCrunch always (so far) fails to build the project with the trace output:

An error occurred while analysing this project after it was built: NCrunch encountered an unexpected error occurred while building an environment to analyse an assembly: nCrunch.TaskRunner.Ipc.IpcConnectionClosedException: The connection has been closed
at nCrunch.Core.ProcessManagement.ExternalProcessManager.(EffectiveProcessorArchitecture , ProcessLoadParameters )
at nCrunch.Core.ProcessManagement.ExternalProcessManager.LoadExternalProcess(ProcessLoadParameters parameters, GridClientId client)
at nCrunch.Core.TestManagement.TestRunnerProcess..()
at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
at nCrunch.Core.TestManagement.TestRunnerProcess.(Nullable`1 , FilePath , GridClientId , CustomVariable[] )
at nCrunch.Core.TestManagement.TestRunnerProcess..()
at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
at nCrunch.Core.TestManagement.TestRunnerProcess.LoadTestRunnerProcessForProjectReturningProcessId(SnapshotComponent snapshotComponent, IList`1 componentsInProcess, TestFrameworkDescription[] testingFrameworks, Nullable`1 newProcessTag, FilePath solutionFilePath, GridClientId client, CustomVariable[] customEnvironmentVariables)
at nCrunch.Core.Processing.AnalysisTaskLogic.DoProcessTaskAndReturnSuccessFlag()

Restarting the NCrunch engine gets it running again.
michaelkroes
#5 Posted : Sunday, January 12, 2020 6:37:44 PM(UTC)
Rank: NCrunch Developer

Groups: Registered
Joined: 9/22/2017(UTC)
Posts: 213
Location: Netherlands

Thanks: 96 times
Was thanked: 46 time(s) in 44 post(s)
Magnus
#6 Posted : Monday, January 13, 2020 5:08:07 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 1/9/2020(UTC)
Posts: 6
Location: Sweden

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
Tried it, same behavior.
Remco
#7 Posted : Tuesday, January 14, 2020 1:03:17 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,117

Thanks: 794 times
Was thanked: 1043 time(s) in 993 post(s)
Magnus;14357 wrote:
Tried it, same behavior.


Sorry to hear that. Would you be able to submit an NCrunch bug report right after this has happened to you? The report may yield some more information about why the process is suddenly disappearing.

Also, just to confirm - you mentioned that there are situations where it does actually run correctly. Is this still the case? If it's intermittent, have you managed to find any pattern around the intermittency?
Magnus
#8 Posted : Friday, January 17, 2020 8:03:55 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 1/9/2020(UTC)
Posts: 6
Location: Sweden

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
I just submitted a bug report, with this trace output in the test window:

An error occurred while analysing this project after it was built: NCrunch encountered an unexpected error occurred while building an environment to analyse an assembly: nCrunch.TaskRunner.Ipc.IpcConnectionClosedException: The connection has been closed
at nCrunch.Core.ProcessManagement.ExternalProcessManager.(EffectiveProcessorArchitecture , ProcessLoadParameters )
at nCrunch.Core.ProcessManagement.ExternalProcessManager.LoadExternalProcess(ProcessLoadParameters parameters, GridClientId client)
at nCrunch.Core.TestManagement.TestRunnerProcess..()
at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
at nCrunch.Core.TestManagement.TestRunnerProcess.(Nullable`1 , FilePath , GridClientId , CustomVariable[] )
at nCrunch.Core.TestManagement.TestRunnerProcess..()
at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
at nCrunch.Core.TestManagement.TestRunnerProcess.LoadTestRunnerProcessForProjectReturningProcessId(SnapshotComponent snapshotComponent, IList`1 componentsInProcess, TestFrameworkDescription[] testingFrameworks, Nullable`1 newProcessTag, FilePath solutionFilePath, GridClientId client, CustomVariable[] customEnvironmentVariables)
at nCrunch.Core.Processing.AnalysisTaskLogic.DoProcessTaskAndReturnSuccessFlag()
Remco
#9 Posted : Friday, January 17, 2020 8:06:42 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,117

Thanks: 794 times
Was thanked: 1043 time(s) in 993 post(s)
Thanks for sending through the report.

It looks like the process isn't giving us any error information in the NCrunch logs. This means that something is going wrong inside the platform itself.

Can you see anything inside the windows event viewer related to the process that's blowing up?

Have you managed to establish any pattern around when this happens? Is it intemittent?
Magnus
#10 Posted : Friday, January 17, 2020 2:55:35 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 1/9/2020(UTC)
Posts: 6
Location: Sweden

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
There is nothing that I can see in the Windows Event Viewer.
I can repeat the build problem with so far 100% certainty by chosing "Reload and rebuild selected component" for the test project in the the NCrunch Tests dialog. I then have to cllick "Restart the ncrunch engine" to get it running again.
The problem often show up spontanously when I do significant changes to the workspace, e.g., by switching branches in git.
Remco
#11 Posted : Friday, January 17, 2020 10:56:42 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,117

Thanks: 794 times
Was thanked: 1043 time(s) in 993 post(s)
Are you able to build a sample solution that can produce this issue? Are you able to produce it by running your tests one at a time?
magla
#12 Posted : Saturday, February 8, 2020 12:38:33 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 2/8/2020(UTC)
Posts: 1
Location: Sweden

Was thanked: 1 time(s) in 1 post(s)
The new version 4.3.0.13 solved all the problems I had, thanks! (orginal poster here, on my work-account)
'
1 user thanked magla for this useful post.
Remco on 2/8/2020(UTC)
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.101 seconds.