private void UpdaProtocolTestContext(TestContext context) { if (this.ProtocolTestContext == null) { this.ProtocolTestContext = new VstsTestContext(context); } else { //update protocol test context VstsTestContext vsContext = this.ProtocolTestContext as VstsTestContext; vsContext.Update(context); this.ProtocolTestContext = vsContext; } }
/// <summary> /// Initializes the test suite base class with explicitly given test suite name. /// This method must be called by class initialize method in your test class. /// </summary> /// <param name="testContext">VSTS test context.</param> /// <param name="testSuiteName">The name of the test suite. The test site uses this name to find configuration files.</param> public static void Initialize(TestContext testContext, string testSuiteName) { executionStartTime = DateTime.Now; if (testContext == null) { throw new InvalidOperationException("TestContext should not be null in UnitTestClassBase."); } classCount++; staticTestSuiteName = testSuiteName; if (null == ProtocolTestsManager.GetTestSite(staticTestSuiteName)) { VstsTestContext vstsTestContext = new VstsTestContext(testContext); IConfigurationData config = ConfigurationDataProvider.GetConfigurationData( vstsTestContext.PtfconfigDir, testSuiteName); string testAssemblyName; if (isUseDefaultSuiteName) { testAssemblyName = testSuiteName; isUseDefaultSuiteName = false; } else { testAssemblyName = Assembly.GetCallingAssembly().GetName().Name; } ProtocolTestsManager.Initialize(config, vstsTestContext, testSuiteName, testAssemblyName); baseTestSite = ProtocolTestsManager.GetTestSite(testSuiteName); ITestSite site = ProtocolTestsManager.GetTestSite(testSuiteName); //registry all checkers RegisterChecker(site); } else { baseTestSite = ProtocolTestsManager.GetTestSite(testSuiteName); } /********************* Display expected runtime of the testsuite ********************** * Log expected execution time of the test suite in the log file * **************************************************************************************/ baseTestSite.Log.Add(LogEntryKind.Comment, "Expected execution time of the test suite (in seconds) is: " + baseTestSite.Properties.Get("ExpectedExecutionTime")); }