Daily Usage Issues

Problem with impacted test for "Track File Dependencies"

Started by GreenMoose on 4,205 views

[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?


        [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.

Edited

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.
Thanks. Maybe this could be reflected in documentation at https://www.ncrunch.net/documentation/V3/reference_project-configuration_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/greenmooseSE/test-repo/tree/try-ncrunchTrackFiles )
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 :)
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)
GreenMoose 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 :(

Post a reply

Log in to reply.