Build/Test Issues

Unit Test fails to get GUID from ThisAssembly.Git.Sha

Started by Hunter-d-_-b on 2,233 views

The NCrunch is returning empty string in the test. However the test works when being run from NUnit test explorer and it returns a GUID.

Check Build Version Is Not Blank()
            {
                IHttpActionResult result = controller.GetBuildVersion();
                OkNegotiatedContentResult<string> version = result as OkNegotiatedContentResult<string>;
                Assert.IsFalse(string.IsNullOrWhiteSpace(version?.Content));
            }

controller code is
        {
            string fileVersion = ThisAssembly.Git.Sha;
            return Ok(fileVersion);
        }




This is the only thing that is stopping us from using this great tool. Can you provide a fix or instructions what settings we need to enable, please? Thank you
Thanks for sharing this. I'm not really sure what is happening here without a bit more context (i.e. full code sample), but is it possible this code is trying to retrieve extra metadata from an assembly under .NET Core?

Can you confirm whether this behaviour is the same after trying the following settings?

- Set 'Instrumentation Mode' to 'Legacy', then try again
- Set 'Instrument Output Assembly' to 'False', then try again

This will help us to determine if this is something being caused by our instrumentation, and if so, which instrumentation routine is responsible.
With these settings it doesn't seem to run any tests at all. It shows green ticks next to 20 projects and question marks next to test projects.
Hunter-d-_-b wrote:With these settings it doesn't seem to run any tests at all. It shows green ticks next to 20 projects and question marks next to test projects.


With the instrumentation off, you'll need to queue up the tests manually as the impact detection will be disabled. This is just temporary so we can see whether the instrumentation is responsible for the problem.
I did queue a few times and nothing happened :/

Interesting thing. When I debug that Controller code with NCrunch I can see the value inside "string fileVersion = ThisAssembly.Git.Sha;" but for some reason when doing return it doesn't return back to the test assertion. It comes back as an empty string.

Post a reply

Log in to reply.