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

Notification

Icon
Error

Dependency tests with NetArchTest failing
gwholdom
#1 Posted : Monday, May 22, 2023 11:46:39 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 1/8/2020(UTC)
Posts: 3
Location: New Zealand

Hi,

I'm using NetArchTest nuget package for some design and dependency tests.

Unfortunately my dependency tests fail in NCrunch, but not with VS2022 testing.

e.g. This Test fails in NCrunch (but not VS2022):

Assert.True(
Types.InCurrentDomain()
.That().ResideInNamespace("MyNamespace.Domain")
.And().HaveName("TestingClass")
.Should()
.OnlyHaveDependenciesOn("System")
.GetResult()
.IsSuccessful);

The class is:

namespace MyNamespace.Domain;

public sealed class TestingClass
{
public Guid Id { get; set; }

public string RoleId { get; set; } = null!;

public Testing() { }
}

PS: I can run my design tests fine with NetArchTest and NCrunch by ensuring [Copy referenced assemblies to workspace] = True and [Copy referenced assemblies to workspace] = True.


Ta,
Grant.
Remco
#2 Posted : Tuesday, May 23, 2023 5:15:38 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 889 times
Was thanked: 1207 time(s) in 1127 post(s)
Hi Grant,

Thanks for sharing this issue.

Looking at this particular framework and from what you've described, my expectation here is that the framework is taking responsibility for its own assembly loading, and as such would be fundamentally incompatible with NCrunch's optimisations.

It might be possible to force it to work with NCrunch by turning on the pre-load assembly references setting, but I suspect that enabling the 'Copy referenced assemblies to workspace' setting may be your only real option here.

Unfortunately with NCrunch there is a balancing act between compatibility and performance. With toolsets like this, we need to be less performant and more compatible.
gwholdom
#3 Posted : Tuesday, May 23, 2023 6:39:29 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 1/8/2020(UTC)
Posts: 3
Location: New Zealand

Thanks for the reply.

I have both [Pre-load all assembly references into test environment] and [Copy referenced assemblies to workspace] set to true but still no dice.

Bit of a bummer because NetArchTest looks useful.


Thanks for your help,
Grant.
Remco
#4 Posted : Tuesday, May 23, 2023 8:33:17 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 889 times
Was thanked: 1207 time(s) in 1127 post(s)
gwholdom;16661 wrote:

I have both [Pre-load all assembly references into test environment] and [Copy referenced assemblies to workspace] set to true but still no dice.


Sorry for the confusion ... I just want to confirm. Does NCrunch not work when the 'Copy referenced assemblies to workspace' setting is turned on? I.e. it's impossible to work at all with this library?
gwholdom
#5 Posted : Wednesday, May 24, 2023 8:20:34 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 1/8/2020(UTC)
Posts: 3
Location: New Zealand

Yes - I tried all the combos of [Pre-load all assembly references into test environment] and [Copy referenced assemblies to workspace] but without any luck.
Depending on the tests and properties set, I was getting a mixture of false positives or false negatives, but getting correct results from VS Unit Testing.
Remco
#6 Posted : Thursday, May 25, 2023 12:16:39 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 889 times
Was thanked: 1207 time(s) in 1127 post(s)
Can you confirm the exceptions you're seeing? Are these assembly resolution issues? If so, is there a specific assembly they are having trouble resolving?
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.040 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download