{"action":"created","issue":{"url":"https://api.github.com/repos/TestStack/TestStack.BDDfy/issues/204","labels_url":"https://api.github.com/repos/TestStack/TestStack.BDDfy/issues/204/labels{/name}","comments_url":"https://api.github.com/repos/TestStack/TestStack.BDDfy/issues/204/comments","events_url":"https://api.github.com/repos/TestStack/TestStack.BDDfy/issues/204/events","html_url":"https://github.com/TestStack/TestStack.BDDfy/issues/204","id":81718237,"number":204,"title":"NUnit test in Release->x64 generates no Scenario name","user":{"login":"lukeschafer","id":980396,"avatar_url":"https://avatars.githubusercontent.com/u/980396?v=3","gravatar_id":"","url":"https://api.github.com/users/lukeschafer","html_url":"https://github.com/lukeschafer","followers_url":"https://api.github.com/users/lukeschafer/followers","following_url":"https://api.github.com/users/lukeschafer/following{/other_user}","gists_url":"https://api.github.com/users/lukeschafer/gists{/gist_id}","starred_url":"https://api.github.com/users/lukeschafer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lukeschafer/subscriptions","organizations_url":"https://api.github.com/users/lukeschafer/orgs","repos_url":"https://api.github.com/users/lukeschafer/repos","events_url":"https://api.github.com/users/lukeschafer/events{/privacy}","received_events_url":"https://api.github.com/users/lukeschafer/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-05-28T02:15:45Z","updated_at":"2015-05-28T07:46:57Z","closed_at":null,"body":"OK so I reported this on Twitter but had trouble repro'ing. Finally did it. Our solution is likely to be to run the tests in Debug mode on the CI server, and you are probably going to have problems fixing this, but reporting anyway.\r\n\r\nOverview:\r\nRunning tests in x64 Release mode causes inlining to occur that drops things from the call stack, making the auto-discovery of scenario names impossible.\r\n\r\nSetup:\r\n.net 4.5 or 4.5.2, Release mode, x64 target (or anycpu on 64bit machine), optimizations on or off, doesn't matter\r\nnunit + bddfy\r\n\r\n```C#\r\nnamespace TestBddfyNames\r\n{\r\n    [TestFixture]\r\n    public class MyTests\r\n    {\r\n        [Test]\r\n        public void SomethingShouldDoSomething()\r\n        {\r\n            this.Given(x => x.GivenSomething())\r\n                .When(x => x.WhenSomething())\r\n                .Then(x => x.ThenSomething())\r\n                .BDDfy();\r\n        }\r\n        private void GivenSomething()\r\n        {\r\n        }\r\n        private void WhenSomething()\r\n        {\r\n            \r\n        }\r\n        private void ThenSomething()\r\n        {\r\n            \r\n        }\r\n    }\r\n}\r\n```\r\nSome info:\r\nhttp://www.hanselman.com/blog/ReleaseISNOTDebug64bitOptimizationsAndCMethodInliningInReleaseBuildCallStacks.aspx\r\n\r\nNote that adding `[MethodImpl(MethodImplOptions.NoInlining)]` to the test method fixes it.\r\n\r\n```C#\r\nnamespace TestBddfyNames\r\n{\r\n    [TestFixture]\r\n    public class MyTests\r\n    {\r\n        [Test]\r\n        [MethodImpl(MethodImplOptions.NoInlining)]\r\n        public void SomethingShouldDoSomething()\r\n        {\r\n            this.Given(x => x.GivenSomething())\r\n                .When(x => x.WhenSomething())\r\n                .Then(x => x.ThenSomething())\r\n                .BDDfy();\r\n        }\r\n\r\n        private void GivenSomething()\r\n        {\r\n        }\r\n\r\n        private void WhenSomething()\r\n        {\r\n\r\n        }\r\n\r\n        private void ThenSomething()\r\n        {\r\n\r\n        }\r\n    }\r\n}\r\n```\r\n\r\nBefore I understood the cause, I had known it was to do with the stack trace so I worked around it with my own extension method that seemed to work (use in place of .BDDfy()):\r\n\r\n```\r\n        public static Story BDDfyWithAutoName(this object testObject, [CallerMemberName] string callerName = \"\")\r\n        {\r\n            if (string.IsNullOrWhiteSpace(callerName)) callerName = new StackFrame(1).GetMethod().Name;\r\n            return testObject.BDDfy(Configurator.Scanners.Humanize(callerName));\r\n        }\r\n```"},"comment":{"url":"https://api.github.com/repos/TestStack/TestStack.BDDfy/issues/comments/106215234","html_url":"https://github.com/TestStack/TestStack.BDDfy/issues/204#issuecomment-106215234","issue_url":"https://api.github.com/repos/TestStack/TestStack.BDDfy/issues/204","id":106215234,"user":{"login":"JakeGinnivan","id":453152,"avatar_url":"https://avatars.githubusercontent.com/u/453152?v=3","gravatar_id":"","url":"https://api.github.com/users/JakeGinnivan","html_url":"https://github.com/JakeGinnivan","followers_url":"https://api.github.com/users/JakeGinnivan/followers","following_url":"https://api.github.com/users/JakeGinnivan/following{/other_user}","gists_url":"https://api.github.com/users/JakeGinnivan/gists{/gist_id}","starred_url":"https://api.github.com/users/JakeGinnivan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JakeGinnivan/subscriptions","organizations_url":"https://api.github.com/users/JakeGinnivan/orgs","repos_url":"https://api.github.com/users/JakeGinnivan/repos","events_url":"https://api.github.com/users/JakeGinnivan/events{/privacy}","received_events_url":"https://api.github.com/users/JakeGinnivan/received_events","type":"User","site_admin":false},"created_at":"2015-05-28T07:46:57Z","updated_at":"2015-05-28T07:46:57Z","body":"Approval tests manages to detect this and throw an error as I have hit the same error before.\r\n\r\nI wonder where the method actually gets inlined to? I really don't understand how a test method can be inlined."}}