{"action":"created","issue":{"url":"https://api.github.com/repos/xunit/xunit/issues/440","labels_url":"https://api.github.com/repos/xunit/xunit/issues/440/labels{/name}","comments_url":"https://api.github.com/repos/xunit/xunit/issues/440/comments","events_url":"https://api.github.com/repos/xunit/xunit/issues/440/events","html_url":"https://github.com/xunit/xunit/issues/440","id":89810517,"number":440,"title":"Lazy F# test functions with commas report incorrect stack trace","user":{"login":"ploeh","id":242165,"avatar_url":"https://avatars.githubusercontent.com/u/242165?v=3","gravatar_id":"","url":"https://api.github.com/users/ploeh","html_url":"https://github.com/ploeh","followers_url":"https://api.github.com/users/ploeh/followers","following_url":"https://api.github.com/users/ploeh/following{/other_user}","gists_url":"https://api.github.com/users/ploeh/gists{/gist_id}","starred_url":"https://api.github.com/users/ploeh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ploeh/subscriptions","organizations_url":"https://api.github.com/users/ploeh/orgs","repos_url":"https://api.github.com/users/ploeh/repos","events_url":"https://api.github.com/users/ploeh/events{/privacy}","received_events_url":"https://api.github.com/users/ploeh/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/xunit/xunit/labels/Pending","name":"Pending","color":"006b75"},{"url":"https://api.github.com/repos/xunit/xunit/labels/type:%20Bug","name":"type: Bug","color":"0052cc"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-06-20T19:53:12Z","updated_at":"2015-07-04T10:46:19Z","closed_at":null,"body":"In F#, you can give functions names with white space, punctuation, etc. using double backticks:\r\n\r\n```F#\r\nlet ``This is my function`` () = ()\r\n```\r\n\r\nThe name of the function is \"This is my function\", complete with spaces. You can also use other unusual characters, such as commas:\r\n\r\n```F#\r\n[<Fact>]\r\nlet ``fact,Normal`` () = 1 / 0\r\n```\r\n\r\nThe above function has a comma in its name, and always fails with a `DivideByZeroException`. So far, all is good.\r\n\r\n# Lazy tests, no commas\r\n\r\nYou can also write a test that contains a lazy evaluation:\r\n\r\n```F#\r\n[<Fact>]\r\nlet ``fact Lazy`` () = (lazy (1 / 0)).Value\r\n```\r\n\r\nThis wraps the division by zero in a lazy computation, and then forces evaluation by accessing its `Value`. Obviously, we expect this to fail, and it does:\r\n\r\n![image](https://cloud.githubusercontent.com/assets/242165/8266636/9adef3a6-1739-11e5-890b-1d3b92c1dde5.png)\r\n\r\nAs you can see from this screen shot from the Visual Studio Test Runner, the stack trace contains two clickable locations. This is to be expected, because the exception is thrown from the expression within the lazy computation, and then again when accessing the `Value`. In this degenerate example, these locations are both of the same line of code, but this doesn't have to be the case at all. In fact, I originally discovered the behaviour described below exactly because I had these parts spread out - in fact, the lazy evaluation was done by FsCheck.\r\n\r\nAll is still good.\r\n\r\n# Lazy tests with commas\r\n\r\nNow change the above test by replacing the space in the name with a comma:\r\n\r\n```F#\r\n[<Fact>]\r\nlet ``fact,Lazy`` () = (lazy (1 / 0)).Value\r\n```\r\n\r\nWhen I run this, I get this result:\r\n\r\n![image](https://cloud.githubusercontent.com/assets/242165/8266666/7e186e76-173b-11e5-8c5a-613f6c866f3b.png)\r\n\r\nNotice that the top entry in the stack trace is no longer clickable, and also strangely formatted.\r\n\r\n# Further observations\r\n\r\nHere, I've chosen to represent the problem with screen shots from the Visual Studio Test Runner. One strange observation is that if I right-click on the test error and click **Copy All**, I get a text representation of the error.\r\n\r\nWhen I compare the two errors, I can't discern what would cause one of them to be correctly formatted, but the other one incorrectly formatted.\r\n\r\nThis is further compounded by looking at the output from the console runner:\r\n\r\n```\r\n$ packages/xunit.runner.console.2.0.0/tools/xunit.console.exe Library2/bin/Debug/Library2.dll\r\nxUnit.net console test runner (64-bit .NET 4.0.30319.34209)\r\nCopyright (C) 2015 Outercurve Foundation.\r\n\r\nDiscovering: Library2\r\nDiscovered:  Library2\r\nStarting:    Library2\r\n   Repro.fact Lazy [FAIL]\r\n      System.DivideByZeroException : Attempted to divide by zero.\r\n      Stack Trace:\r\n         Library2\\Library1.fs(11,0): at Repro.fact Lazy@11.Invoke(Unit unitVar)\r\n            at System.Lazy`1.CreateValue()\r\n            at System.Lazy`1.LazyInitValue()\r\n         Library2\\Library1.fs(11,0): at Repro.fact Lazy()\r\n   Repro.fact,Lazy [FAIL]\r\n      System.DivideByZeroException : Attempted to divide by zero.\r\n      Stack Trace:\r\n         Library2\\Library1.fs(14,0): at Repro.fact\\,Lazy@14.Invoke(Unit unitVar)\r\n            at System.Lazy`1.CreateValue()\r\n            at System.Lazy`1.LazyInitValue()\r\n         Library2\\Library1.fs(14,0): at Repro.fact,Lazy()\r\n   Repro.fact,Normal [FAIL]\r\n      System.DivideByZeroException : Attempted to divide by zero.\r\n      Stack Trace:\r\n         Library2\\Library1.fs(8,0): at Repro.fact,Normal()\r\nFinished:    Library2\r\n\r\n=== TEST EXECUTION SUMMARY ===\r\n   Library2  Total: 3, Errors: 0, Failed: 3, Skipped: 0, Time: 0,281s\r\n```\r\n\r\nIf there's a difference in formatting, I can't see it.\r\n\r\nThis would seem to indicate a bug in the Visual Studio Test Runner, but if you run the tests with the [TestDriven.Net](http://testdriven.net) Visual Studio add-in, you can see the problem here as well:\r\n\r\n```\r\n------ Test started: Assembly: Library2.dll ------\r\n\r\nTest 'Repro.fact Lazy' failed: System.DivideByZeroException : Attempted to divide by zero.\r\n\tc:\\Users\\Mark\\Desktop\\Library2\\Library2\\Library1.fs(11,0): at Repro.fact Lazy@11.Invoke(Unit unitVar)\r\n\tat System.Lazy`1.CreateValue()\r\n\tat System.Lazy`1.LazyInitValue()\r\n\tat System.Lazy`1.get_Value()\r\n\tc:\\Users\\Mark\\Desktop\\Library2\\Library2\\Library1.fs(11,0): at Repro.fact Lazy()\r\n\r\nTest 'Repro.fact,Lazy' failed: System.DivideByZeroException : Attempted to divide by zero.\r\n\t   at Repro.fact\\,Lazy@14.Invoke(Unit unitVar) in c:\\Users\\Mark\\Desktop\\Library2\\Library2\\Library1.fs:line 14\r\n\tat System.Lazy`1.CreateValue()\r\n\tat System.Lazy`1.LazyInitValue()\r\n\tat System.Lazy`1.get_Value()\r\n\tc:\\Users\\Mark\\Desktop\\Library2\\Library2\\Library1.fs(14,0): at Repro.fact,Lazy()\r\n\r\nTest 'Repro.fact,Normal' failed: System.DivideByZeroException : Attempted to divide by zero.\r\n\tc:\\Users\\Mark\\Desktop\\Library2\\Library2\\Library1.fs(8,0): at Repro.fact,Normal()\r\n\r\n0 passed, 3 failed, 0 skipped, took 0,95 seconds (xUnit.net 2.0.0 build 2929).\r\n```\r\n\r\nThis may seem like quite a ridiculous and insignificant problem, but I originally discovered it in some of my [FsCheck](https://github.com/fscheck/FsCheck) properties (tests).\r\n\r\nFirst, I spent a couple of hours attempting to hunt down the bug in FsCheck, until I realised that I could reproduce it with vanilla xUnit.net.\r\n\r\nThen I thought it was a bug in TestDriven.Net, until I realised that it also manifests itself in the Visual Studio Test Runner.\r\n\r\nSubsequently I used a couple of hours attempting to hunt down the reason looking through the xUnit.Net code base, but didn't feel enlightened.\r\n\r\nBefore I use more time and energy on this, I wanted to ask about this issue here. When stuck, it sometimes helps to ask for help :smile: "},"comment":{"url":"https://api.github.com/repos/xunit/xunit/issues/comments/118499818","html_url":"https://github.com/xunit/xunit/issues/440#issuecomment-118499818","issue_url":"https://api.github.com/repos/xunit/xunit/issues/440","id":118499818,"user":{"login":"ploeh","id":242165,"avatar_url":"https://avatars.githubusercontent.com/u/242165?v=3","gravatar_id":"","url":"https://api.github.com/users/ploeh","html_url":"https://github.com/ploeh","followers_url":"https://api.github.com/users/ploeh/followers","following_url":"https://api.github.com/users/ploeh/following{/other_user}","gists_url":"https://api.github.com/users/ploeh/gists{/gist_id}","starred_url":"https://api.github.com/users/ploeh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ploeh/subscriptions","organizations_url":"https://api.github.com/users/ploeh/orgs","repos_url":"https://api.github.com/users/ploeh/repos","events_url":"https://api.github.com/users/ploeh/events{/privacy}","received_events_url":"https://api.github.com/users/ploeh/received_events","type":"User","site_admin":false},"created_at":"2015-07-04T10:46:19Z","updated_at":"2015-07-04T10:46:19Z","body":"As reported, this was on xunit.core 2.0.0.\r\n\r\nI've attempted to try with 2.1 beta 3, but this isn't possible:\r\n\r\n```\r\n> Get-Package\r\nNo packages installed.\r\n> Install-Package xunit.core -Pre\r\nAttempting to resolve dependency 'xunit.extensibility.core (= 2.1.0-beta3-build3029)'.\r\nAttempting to resolve dependency 'xunit.abstractions (= 2.0.0)'.\r\nInstall-Package : 'xunit.core' already has a dependency defined for 'xunit.extensibility.core'.\r\nAt line:1 char:1\r\n+ Install-Package xunit.core -Pre\r\n+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n    + CategoryInfo          : NotSpecified: (:) [Install-Package], InvalidOperationException\r\n    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand\r\n> Get-Package\r\nNo packages installed.\r\n```"}}