开发者

MS UnitTest - Private Accessor not always recognized

This problem doesn't occur in all projects, hence it makes it even more frustrating.

If I click on a Private method to create a unit test, it would generate a TestProject assembly and create a predefined class in there. It would also create a Accessor for that class.

[TestMethod()]
        [DeploymentItem("xxx.Client.dll")]
        public void PopulateIncomeCostsDataSetTest()
        {
            CashFlowOperations_Accessor target = new CashFlowOperations_Accessor(); // TODO: Initialize to an appropriate value
            CashflowModel cashflowModel = null; // TODO: Initialize to an appropriate value
            CashflowDataSet ds = null; // TODO: Ini开发者_JAVA百科tialize to an appropriate value
            target.PopulateIncomeCostsDataSet(cashflowModel, ds);
            Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }

As long as I create this unit test for private methods in a library assembly (dll) its all fine, but if I create it for a Console application where [DeploymentItem("xxx.exe")] is an executable, my Accessor stays in red color and I cant access the internal private methods of that accessor.


I don't know if this helps (I haven't been able to reproduce your error) but in Local.testsettings there is an option to enable deployment.

  • Open Local.testsettings from Solution Items
  • Select "Deployment" item in listbox
  • Check "Enable deployment"

This must be done before you can unit test in applications instead of libraries


This seemed to be a bug in Visual Studio. This can happen in VS 2088 and even VS 2010. The SP1 for VS 2010 solved this problem for me. Hope this helps other people.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜