Search Results

Search found 2 results on 1 pages for 'dbjdbj'.

Page 1/1 | 1 

  • Are TestContext.Properties read only ?

    - by DBJDBJ
    Using Visual Studio generate Test Unit class. Then comment out class initialization method. Inside it add your property, using the testContext argument. //Use ClassInitialize to run code before running the first test in the class [ClassInitialize()] public static void MyClassInitialize(TestContext testContext) { /* * Any user defined testContext.Properties * added here will be erased upon this method exit */ testContext.Properties.Add("key", 1 ) ; // above works but is lost } After leaving MyClassInitialize, properties defined by user are lost. Only the 10 "official" ones are left. This effectively means TestContext.Properties is read only, for users. Which is not clearly documented in MSDN. Please discuss. --DBJ

    Read the article

  • Are TestContext.Properties usable ?

    - by DBJDBJ
    Using Visual Studio generate Test Unit class. Then comment in, the class initialization method. Inside it add your property, using the testContext argument. Upon test app startup this method is indeed called by the testing infrastructure. //Use ClassInitialize to run code before running the first test in the class [ClassInitialize()] public static void MyClassInitialize(TestContext testContext) { /* * Any user defined testContext.Properties * added here will be erased after this method exits */ testContext.Properties.Add("key", 1 ) ; // place the break point here } After leaving MyClassInitialize, any properties added by user are lost. Only the 10 "official" ones are left. Actually TestContext gets overwritten, with the inital offical one, each time before each test method is called. It it not overwritten only if user has test initialization method, the changes made over there are passed to the test. //Use TestInitialize to run code before running each test [TestInitialize()]public void MyTestInitialize(){ this.TestContext.Properties.Add("this is preserved",1) ; } This effectively means TestContext.Properties is "mostly" read only, for users. Which is not clearly documented in MSDN. It seems to me this is very messy design+implementation. Why having TestContext.Properties as an collection, at all ? Users can do many other solutions to have class wide initialization. Please discuss. --DBJ

    Read the article

1