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

Notification

Icon
Error

Problem with impacted test for "Track File Dependencies"
GreenMoose
#1 Posted : Monday, November 26, 2018 1:14:24 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/17/2012(UTC)
Posts: 503

Thanks: 142 times
Was thanked: 66 time(s) in 64 post(s)
[v3.22.01]

I think I am not understanding the idea of track file dependencies properly, I have 2 tests reading file from a library both from file and from an assembly resource (see source at github).

However when I change the json files manually I expect NCrunch to treat the 2 tests as impacted, but they are not. Have I misunderstood how this should be working?

Code:

        [Test]
        public void CanReadJson1FileFromFile()
        {
            string fileContent = ReadFileFromStdLibBinOutput("Generated\\" + JsonFileCopiedToOutputName);
            Assert.IsNotEmpty(fileContent);
            LogIt($"Got content:\n{fileContent}\n");
        }

        [Test]
        public void CanReadJson1FileFromResource()
        {
            string fileContent =
                ReadFileFromStdLibBinAssemblyResource("Generated." + JsonFile2AsEmbeddedResourceName);
            Assert.IsNotEmpty(fileContent);
            LogIt($"Got content:\n{fileContent}\n");
        }


Thanks.
Remco
#2 Posted : Tuesday, November 27, 2018 12:17:29 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 944 times
Was thanked: 1267 time(s) in 1179 post(s)
Hi, thanks for posting.

The tracking of file dependencies for the purposes of impact detection is best effort, since there's quite a few constraints around what we can easily do in this area.

This feature is subject to a couple of critical conditions that I know about:
1. The files being accessed by your code must be included in your project and copied to your build output directory as resource files
2. This feature will not work under .NET Core

It's likely there are other constraints, as the system works using low level API hooks, of which the function can be somewhat environment specific. It's possible that there are file I/O routines that don't trigger the hooks.
GreenMoose
#3 Posted : Tuesday, November 27, 2018 4:15:45 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/17/2012(UTC)
Posts: 503

Thanks: 142 times
Was thanked: 66 time(s) in 64 post(s)
Thanks. Maybe this could be reflected in documentation at https://www.ncrunch.net/...track-file-dependencies in some way?

FWIW, when I did my tests I only managed to get a test impacted if it read a non resource file that was copied to bin output, and it was in a .Net Framework test project instead of dotnet core (although the file itself could be placed in a net standard library, I used the code at https://github.com/green...e/try-ncrunchTrackFiles )
Remco
#4 Posted : Tuesday, November 27, 2018 11:14:09 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 944 times
Was thanked: 1267 time(s) in 1179 post(s)
I expect that the .resx files likely won't trigger the impact detection using this feature, as they get accessed by the runtime prior to the test beginning its execution.

Good catch on the documentation. I'll make sure this gets updated with our next release :)
1 user thanked Remco for this useful post.
GreenMoose on 11/28/2018(UTC)
GreenMoose
#5 Posted : Wednesday, November 28, 2018 11:56:06 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/17/2012(UTC)
Posts: 503

Thanks: 142 times
Was thanked: 66 time(s) in 64 post(s)
Although... It is a real pity this very neat feature does not work with net core. Is there any plans of supporting it?

(my use case involves .NET core web api and generated API client code, which makes it kindof hard since that web api cannot easily be referenced by a .NET 4.6.2 test project)
Remco
#6 Posted : Thursday, November 29, 2018 12:08:42 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 944 times
Was thanked: 1267 time(s) in 1179 post(s)
GreenMoose;12858 wrote:
Although... It is a real pity this very neat feature does not work with net core. Is there any plans of supporting it?


Sadly, this feature is heavily dependent on a 3rd party library that hasn't yet been updated to support .NET Core.

Maybe we'll have a chance to address it in future, but in the near term I don't see a fix happening :(
1 user thanked Remco for this useful post.
GreenMoose on 11/29/2018(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.038 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download