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

Notification

Icon
Error

Tests not discovered in net462 CPS .csproj
jnm236
#1 Posted : Friday, March 10, 2017 3:23:52 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/25/2015(UTC)
Posts: 57
Location: United States of America

Thanks: 1 times
Was thanked: 4 time(s) in 4 post(s)
We are motivated to move away from the old .csproj + project.json for our net462 projects.

Building, discovering, running and debugging works perfectly in VS2017 RTM (NUnit test adapter extension installed) and in ReSharper 2017.1 EAP 4.
NCrunch 3.5 (and NCrunch 3.2) builds but does not discover any tests.

Here's the entire project to reproduce:

Sample net462 test project.csproj:
Code:

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

  <PropertyGroup>    
    <TargetFramework>net462</TargetFramework>
    
    <!-- Workaround for https://github.com/nunit/nunit3-vs-adapter/issues/296 -->
    <DebugType>Full</DebugType>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="NUnit" Version="3.6.1" />
  </ItemGroup>

</Project>


UnitTest1.cs:
Code:

using NUnit.Framework;

namespace Sample_net462_test_project
{
    [TestFixture]
    public class UnitTest1
    {
        [Test]
        public void TestMethod1()
        {
        }
    }
}
Remco
#2 Posted : Saturday, March 11, 2017 6:13:51 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
damianh
#3 Posted : Saturday, March 11, 2017 11:10:03 AM(UTC)
Rank: Member

Groups: Registered
Joined: 5/5/2014(UTC)
Posts: 18
Location: Netherlands

Thanks: 1 times
Was thanked: 3 time(s) in 3 post(s)
I'm experiencing the same thing except that ncrunch is not even building the projects. 3.6.0.1 does not fix it.
jnm236
#4 Posted : Saturday, March 11, 2017 1:23:01 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/25/2015(UTC)
Posts: 57
Location: United States of America

Thanks: 1 times
Was thanked: 4 time(s) in 4 post(s)
Thanks Remco! Much appreciated!

One of my test projects is now working properly with NCrunch. The only weird thing with this project is that it gives this warning, even though .NET Core is not in the picture:

Quote:
The dotnet package restore command timed out: "C:\Program Files\dotnet\dotnet.exe" restore "path\to\testproject.csproj"


I'm used to nuget restore and msbuild /t:restore; I'm not familiar with dotnet restore being used on a .NET Framework-only project. So I was surprised, but anyhow.

The rest of my test projects do not build at all with 3.6. All the errors are of the form "The type or namespace name '*' could not be found (are you missing a using directive or an assembly reference?)"
However all the errors point to missing third-party GAC-referenced assembles. They are not NuGet references.

Would it be helpful if I put together a repro for either of these scenarios?
Remco
#5 Posted : Saturday, March 11, 2017 9:42:04 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
jnm236;9938 wrote:

One of my test projects is now working properly with NCrunch. The only weird thing with this project is that it gives this warning, even though .NET Core is not in the picture:

[quote]The dotnet package restore command timed out: "C:\Program Files\dotnet\dotnet.exe" restore "path\to\testproject.csproj"

I'm used to nuget restore and msbuild /t:restore; I'm not familiar with dotnet restore being used on a .NET Framework-only project. So I was surprised, but anyhow.


I think I can see how this would happen. I'll see if I can do some tuning on this.

jnm236;9938 wrote:

The rest of my test projects do not build at all with 3.6. All the errors are of the form "The type or namespace name '*' could not be found (are you missing a using directive or an assembly reference?)"
However all the errors point to missing third-party GAC-referenced assembles. They are not NuGet references.

Would it be helpful if I put together a repro for either of these scenarios?


If you could, that would be really great. I'm not sure how MSBuild could fail to resolve a GAC reference. This one has me a bit confused.
jnm236
#6 Posted : Monday, March 13, 2017 11:31:08 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/25/2015(UTC)
Posts: 57
Location: United States of America

Thanks: 1 times
Was thanked: 4 time(s) in 4 post(s)
For the GAC issue, I actually don't think it's your fault. See my second comment:
https://github.com/dotne...#issuecomment-286236502

Somewhere in the course of fixing the GAC issue and other issues like this one, the dotnet restore warning has disappeared too.

I'll let you know if I can reproduce it again.
Remco
#7 Posted : Monday, March 13, 2017 11:35:00 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
jnm236;9960 wrote:
For the GAC issue, I actually don't think it's your fault. See my second comment:
https://github.com/dotne...#issuecomment-286236502

Somewhere in the course of fixing the GAC issue and other issues like this one, the dotnet restore warning has disappeared too.

I'll let you know if I can reproduce it again.


This is very interesting. It does definitely feel like assembly referencing is a bit of a mess at the moment.

MS do seem to be moving away from the GAC. I would hope that this move doesn't break too much backwards compatibility.
Remco
#8 Posted : Wednesday, March 15, 2017 4:37:38 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
A fix for the test discovery problem under CPS projects is now out with v3.6.
jnm236
#9 Posted : Friday, March 17, 2017 12:16:08 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/25/2015(UTC)
Posts: 57
Location: United States of America

Thanks: 1 times
Was thanked: 4 time(s) in 4 post(s)
It works great for the CPS test projects.

I have an odd behavior, no idea if it is related. One of the test projects ran (which are all CPS now) and a single test failed. I ran the test a bunch more times.

Later on, NCrunch stopped running tests for that project and I saw that it the project was failing to build. It was giving the good old "file is in use, try 3 of 10" kind of thing.
So I closed Visual Studio and reopened it. Not NCrunch says the project is failing but gives no error. I used the "Resync, rebuild and rerun all" button and it still wouldn't build.
Builds fine in VS.

I tried Advanced > Browse to workspace last built for selected project and nothing happens when I click it.

I'm not sure why that would persist across a restart of VS. Next I'm going to try rebooting.
jnm236
#10 Posted : Friday, March 17, 2017 12:24:23 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/25/2015(UTC)
Posts: 57
Location: United States of America

Thanks: 1 times
Was thanked: 4 time(s) in 4 post(s)
Rebooted, no change.

Edited a file to make it it fail to build in VS. To my surprise, it failed in NCrunch with the correct error message. So I fixed the intentional error. Then the project built in VS but not in NCrunch. NCrunch shows the same error message that it did back when the file had the error.
jnm236
#11 Posted : Friday, March 17, 2017 12:26:40 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/25/2015(UTC)
Posts: 57
Location: United States of America

Thanks: 1 times
Was thanked: 4 time(s) in 4 post(s)
Hang on, hang on... I reverted all edits to the test and NCrunch started building the project again. I have a hunch it doesn't like my local functions.

jnm236
#12 Posted : Friday, March 17, 2017 12:31:14 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/25/2015(UTC)
Posts: 57
Location: United States of America

Thanks: 1 times
Was thanked: 4 time(s) in 4 post(s)
Yep, confirmed. Project builds fine in NCrunch until I add an empty local function. Then it gives "Beginning retry 1 in 1000ms. The process cannot access the file 'x.dll' because it is being used by another process." and eventually fails all 10 times.

One time just now I saw it build successfully with an empty local function, so I have no idea why it's not consistent.
What is consistent is that if I remove all local functions, NCrunch never has a problem.
jnm236
#14 Posted : Friday, March 17, 2017 1:03:14 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/25/2015(UTC)
Posts: 57
Location: United States of America

Thanks: 1 times
Was thanked: 4 time(s) in 4 post(s)
Repro:

Code:

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

  <PropertyGroup>    
    <TargetFramework>net462</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
    <PackageReference Include="MSTest.TestAdapter" Version="1.1.11" />
    <PackageReference Include="MSTest.TestFramework" Version="1.1.11" />
  </ItemGroup>

</Project>


This fails to build in NCrunch, works in VS:

Code:

using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace UnitTestProject1
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void TestMethod1()
        {
            void LocalFunction()
            {
                Discard(new Action(LocalFunction));
            }
        }

        private static void Discard<T>(T value)
        {
        }
    }
}




However this does NOT fail:
Code:

            void LocalFunction()
            {
                _ = new Action(LocalFunction);
            }
Remco
#15 Posted : Friday, March 17, 2017 10:59:09 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Hi,

Thanks for sharing this problem. I've reproduced it exactly as you've described.

The problem is caused by NCrunch's IL hashing for impact detection. The recursion here is causing the IL hashing algorithm to bomb out with a stack overflow.

I'll see what I can do to implement a fix.

Meanwhile, you may be able to work around the problem by redesign the code to avoid the recursion, or by changing your 'Impact detection mode' to 'WatchText'.
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.092 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download