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

Notification

Icon
Error

DataTestMethod with Enumerators fail in NCrunch
Kaerwek
#1 Posted : Monday, August 7, 2017 8:05:11 AM(UTC)
Rank: Member

Groups: Registered
Joined: 8/7/2017(UTC)
Posts: 23
Location: Finland

We're using DataTestMethods with enumerators, e.g.

[DataTestMethod]
[DataRow(AlignmentX.Center, "middle", DisplayName = "Returns \"middle\" for given AlignmentX = Center")]
[DataRow(AlignmentX.Left, "start", DisplayName = "Returns \"start\" for given AlignmentX = Left")]
[DataRow(AlignmentX.Right, "end", DisplayName = "Returns \"end\" for given AlignmentX = Right")]
public void Test(object input, string expected)

The tests fail because NCrunch converts the chosen enumerator to the backend value. When entering a breakpoint in debugger mode on first line, I see that input is an integer, 2, in the first case.

If I had a test that only tested for AlignmentX, I could perhaps code past it, but currently I have loads of other datarows and datatypes. Forcing everyone in the organization (since all dont use NCrunch), to create specific tests for DataTestMethods that use a specific enumerator isn't really feasible either.


Is this a known issue?
Remco
#2 Posted : Monday, August 7, 2017 8:09:41 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,145

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi,

Thanks for sharing this issue.

Until now, I was not aware of this issue, but it does make sense that it could exist. There is some complexity in the handling of DataRow parameters, and you've managed to find an alignment hole.

I'll see what I can do about getting this fixed in the next build.
Remco
#3 Posted : Thursday, August 31, 2017 1:32:35 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,145

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
I've taken a deeper look into this issue, and prepared a fix expected to be in a new version of NCrunch released by early next week.

The fix is narrow in scope. It will only work when MSTest is set to use a framework utilisation type of 'Dynamic Analysis'. This can be adjusted in your NCrunch configuration.

For performance reasons, the default mode of operation under MSTest is set to 'Static Analysis'. Unfortunately, static analysis does have some compatibility trade-offs that can affect edge cases like this one. If you are in a situation where other team members are using different test runners to NCrunch and alignment between runners is critically important, I recommend using Dynamic Analysis instead.
Kaerwek
#4 Posted : Tuesday, November 7, 2017 7:00:56 AM(UTC)
Rank: Member

Groups: Registered
Joined: 8/7/2017(UTC)
Posts: 23
Location: Finland

Hi Remco,

After seeing your reply since two months back, about a fix to this issue being included in a new version in the patch, I was hopeful that I'd find a patch or version release somewhere by now.

I have however 3.11.0.9, which seems to be latest. Is there a patch somewhere I can download and fix this issue with?
Remco
#5 Posted : Tuesday, November 7, 2017 7:34:10 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,145

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Kaerwek
#6 Posted : Tuesday, November 7, 2017 8:05:44 AM(UTC)
Rank: Member

Groups: Registered
Joined: 8/7/2017(UTC)
Posts: 23
Location: Finland

Thanks Remco,

I Unblocked the nCrunch.VSIntegration2017.dll file, in order to get Visual Studio to load NCrunch properly without causing an exception.

However, I'm seeing this for every project in the NCrunch Tests tab:

nCrunch.TaskRunner.Ipc.IpcConnectionClosedException: The connection has been closed
at nCrunch.Core.ProcessManagement.ExternalProcessManager.(ProcessorArchitecture , ProcessLoadParameters )
at nCrunch.Core.ProcessManagement.ExternalProcessManager.LoadExternalProcess(ProcessLoadParameters parameters, GridClientId client)
at nCrunch.Core.BuildManagement.BuildProcessLauncher..()
at nCrunch.Common.PerformanceTracking.PerfTracker.TryTrackActivity(String name, Action activity)
at nCrunch.Core.BuildManagement.BuildProcessLauncher.(Action`1 , ProcessorArchitecture , GridClientId , BuildSystemParameters , IList`1 )
at nCrunch.Core.BuildManagement.BuildProcessLauncher.AnalyseComponentBuildInExternalProcess(ComponentLoadParameters parameters, IList`1 customEnvironmentVariables)
at nCrunch.Client.ComponentLoader.SnapshotComponentLoader.(ProcessorArchitecture , String )
at nCrunch.Client.ComponentLoader.SnapshotComponentLoader.CreateComponentFromXml(FilePath projectFilePath, ParsedBuildXml projectXml, FilePath solutionFilePath, String[] additionalFilesToIncludeAtSolutionLevel, Boolean isLoadedFromFile, VisualStudioVersion vsVersion, ComponentUniqueName componentName, TaskSettings componentTaskSettings, Exception parseException, String targetFramework)

Is there anything I can do to get NCrunch running with this build, or is it unstable?
Kaerwek
#7 Posted : Tuesday, November 7, 2017 8:06:45 AM(UTC)
Rank: Member

Groups: Registered
Joined: 8/7/2017(UTC)
Posts: 23
Location: Finland

Oh, and I only grabbed what I thought I needed, the NCrunch_VS2017_3.12.0.4.zip.
Remco
#8 Posted : Tuesday, November 7, 2017 8:22:58 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,145

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
I recommend installing via the MSI rather than the ZIP, if possible.

My first guess would be that the O/S is blocking NCrunch from running its task runners. If you need to install the ZIP, check that the files aren't being blocked. See here for specifics: http://www.ncrunch.net/documentation/manual-installation-instructions.
Kaerwek
#9 Posted : Tuesday, November 7, 2017 9:00:40 AM(UTC)
Rank: Member

Groups: Registered
Joined: 8/7/2017(UTC)
Posts: 23
Location: Finland

Hi,

Got it installed and working, however the issue, Datarow with enums don't work still.

I confirmed that I'm running now 3.12.0.4. But I still see these failing tests. And entering debugger mode, I see the integer as input still.

//
// Summary:
// Svg vector effect
public enum VectorEffect
{
//
// Summary:
// No effect
None = 0,
//
// Summary:
// Non scaling stroke
NonScalingStroke = 1,
//
// Summary:
// Inherit
Inherit = 2
}

Best regards,
Kaerwek
Kaerwek
#11 Posted : Tuesday, November 7, 2017 9:02:50 AM(UTC)
Rank: Member

Groups: Registered
Joined: 8/7/2017(UTC)
Posts: 23
Location: Finland

It's later compared against this in a switch statement, and as it's passed as an pure integer, it fails the switch case:

case VectorEffect x: return $"'{x.GetString()}'";
Remco
#12 Posted : Tuesday, November 7, 2017 9:22:29 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,145

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Can you confirm whether you set your framework utilisation type for MSTest to DynamicAnalysis? As described earlier, it just wasn't feasible to support all use cases of the DataRow under StaticAnalysis.
Kaerwek
#13 Posted : Thursday, December 14, 2017 8:32:08 AM(UTC)
Rank: Member

Groups: Registered
Joined: 8/7/2017(UTC)
Posts: 23
Location: Finland

Just installed newest version, 3.12.0.15, and can confirm that by having UseDynamicAnalysis, the tests no longer fail.

Thanks Remco!
Remco
#14 Posted : Thursday, December 14, 2017 10:08:38 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,145

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Great! Thanks for confirming!
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.127 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download