代码之家  ›  专栏  ›  技术社区  ›  Budda

testcontext为空

  •  7
  • Budda  · 技术社区  · 15 年前

    非常简单的测试:

    [TestClass]
    public class MyTestClass
    {
        private TestContext _testContext;
        protected TestContext TestContext
        {
            get { return _testContext; }
            set { _testContext = value; }
        }
    
        [TestMethod]
        [HostType("ASP.NET")]
        [UrlToTest("http://localhost/MyPage.aspx")]
        public void TestMyPage()
        {
            Assert.IsNotNull(TestContext);
        }
    }
    

    失败。。。现在我使用的是VS2008开发版。有没有可能解决这个问题?或者我需要一个测试(或团队套件)版本?

    谢谢。

    p.s.需要访问testcontext对象才能访问其requestedpage属性

    1 回复  |  直到 11 年前
        1
  •  9
  •   womp    15 年前

    我很确定testcontext必须是公共属性,框架才能为您设置它。你试过把它公之于众吗?

    推荐文章