2013-08-19 4 views
1

Visual Studio 2012의 궁극적 인 최상위 웹 성능 테스트를 사용하고 있습니다.웹 테스트 성능을 사용하는 동안 발생하는 오류 Visual Studio 2012

수동으로 테스트를 만들었으며 웹 테스트 플러그인을 통해 솔루션의 App.config 파일에서 값을 가져 오려고합니다. 의 App.config에

코드 :

(xml code) 
<configuration> 
<appSettings> 
<add key="PaymentServiceURL" value="MyURL" /> 
</appSettings> 
<connectionStrings> 
... 
</connectionStrings> 

플러그인 코드 :

using Microsoft.VisualStudio.TestTools.WebTesting; 
using PaymentServiceAPITestNew.ConfigManager; 
using System; 
using System.Collections.Generic; 
using System.IO; 


public class Init : WebTestPlugin 
{ 
    public override void PreWebTest(object sender, PreWebTestEventArgs e) 
    { 
     //List<APIObj> testList = null; 
     string feedsURL = MyConfigManager.GetAppSettings("PaymentServiceURL"); 
     e.WebTest.Context["PaymentServiceURL"] = feedsURL; 
    } 
    ..... 

코드 MyConfigManager는 :

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Configuration; 
using log4net; 
using System.IO; 

public static class MyConfigManager 
{ 
    ... 
    public static string GetConnectionString(string key) 
    { 
     string result = string.Empty; 
     if (connectionStrings == null || (connectionStrings != null && connectionStrings.Count == 0)) 
     { 
      connectionStrings = new Dictionary<string, string>(); 
      var config = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Reflection.Assembly.GetCallingAssembly().Location); 
      foreach (System.Configuration.ConnectionStringSettings conn in config.ConnectionStrings.ConnectionStrings) 
       connectionStrings.Add(conn.Name, conn.ConnectionString); 
     } 

     connectionStrings.TryGetValue(key, out result); 
     return result; 
    } 
    ... 

웹 테스트는로 이동했는데 플러그인을 사용하여 app.config를 열고 PaymentServiceUrl을 가져 오지만 그는 해당 플러그인을 사용하지 않습니다.

결과는 다음과 같습니다 요청 실패 : 컨텍스트 매개 변수 'PaymentServiceURL는'테스트 컨텍스트에서 찾을 수 없습니다

요청이 실패 : PreWebTest 이벤트에서 예외 : 파일 또는 어셈블리를로드 할 수 없습니다 'PaymentServiceAPITestNew, 버전 = 1.0.0.0, Culture = neutral, PublicKeyToken = null '또는 그 종속성 중 하나입니다. 지정한 파일을 찾을 수 없습니다.

답변

0

Trove Nini라는 NuGet 패키지를 사용했으며 구성 파일 정보를 얻는 데 꽤 효과적입니다.