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

Notification

Icon
Error

Unit Test fails to get GUID from ThisAssembly.Git.Sha
Hunter-d-_-b
#1 Posted : Wednesday, December 18, 2019 11:22:35 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 12/18/2019(UTC)
Posts: 4
Location: United Kingdom

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()
Code:
            {
                IHttpActionResult result = controller.GetBuildVersion();
                OkNegotiatedContentResult<string> version = result as OkNegotiatedContentResult<string>;
                Assert.IsFalse(string.IsNullOrWhiteSpace(version?.Content));
            }

controller code is
Code:
        {
            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
Remco
#2 Posted : Wednesday, December 18, 2019 11:33:22 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
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.
Hunter-d-_-b
#3 Posted : Thursday, December 19, 2019 3:34:51 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 12/18/2019(UTC)
Posts: 4
Location: United Kingdom

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.
Remco
#4 Posted : Thursday, December 19, 2019 10:53:19 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hunter-d-_-b;14246 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.
Hunter-d-_-b
#5 Posted : Friday, December 20, 2019 10:16:36 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 12/18/2019(UTC)
Posts: 4
Location: United Kingdom

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.
Remco
#6 Posted : Friday, December 20, 2019 11:50:59 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Can you try compatibility mode to see if this has any effect on the problem?
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.039 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download