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