This is a migrated thread and some comments may be shown as answers.

How to combine my app.config with the automatically generated test studio app.config

6 Answers 1060 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Justin
Top achievements
Rank 2
Justin asked on 09 May 2013, 05:38 PM
Is it possible to create an app.config and somehow combine it with the app.config that test studio will generate for itself?

I have seen the proposed solution in this thread but I currently have a legacy DLL that expects data to exist in the app.config. The legacy DLL will not know about the ExecutionContext and since the configuration I want to put into the app.config only applies at an application level, I don't want to place it in my machine.config.

Is there some way I can modify the test studio app.config to include my desired xml nodes?

I am currently using the standalone Telerik Test Studio v 122.14.20.0

6 Answers, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 13 May 2013, 03:39 PM
Hello Justin,

To achieve this, you can create a custom config file that will include the Test Studio's settings along with the desired keys from your app.config file. Here is an example of a complete app.config file that contains all of Telerik's configuration settings:
<?xml version="1.0" encoding="utf-8" ?>
   <configuration>
       <configSections>        
               <section name="WebAii.Settings" type="ArtOfTest.WebAii.Core.SettingsConfigSectionHandler,ArtOfTest.WebAii"/>
               <section name="WebAii.Settings.Web" type="ArtOfTest.WebAii.Core.WebSettingsConfigSectionHandler,ArtOfTest.WebAii"/>     
       </configSections>
        
       <WebAii.Settings                   
           logLocation="F:\Log\"
           executionTimeout="30000"
           clientReadyTimeout="20000"                    
           queryEventLogErrorsOnExit="false"          
           executionDelay="0"
           annotateExecution="true"
           annotationMode="All"
           logAnnotations="false"             
           waitCheckInterval="500"      
           createLogFile="true"
           unexpectedDialogAction="HandleAndFailTest"
           xMultiMgr="false"
           elementWaitTimeout="10000">
        </WebAii.Settings>
                
        <WebAii.Settings.Web
            baseUrl=""
            killBrowserProcessOnClose="false"
            defaultBrowser="Chrome"
            enableScriptLogging="false"
            silverlightConnectTimeout="30000"
            silverlightApplicationPath=""
            localWebServer="None"
            webAppPhysicalPath=""
            aspNetDevServerPort="-1"
            enableUILessRequestViewing="false"
            useHttpProxy="false"
            enableSilverlight="false"
            verboseHttpProxy="false">
        </WebAii.Settings.Web
                     
   </configuration>

Now after the WebAii.Settings.Web section add a new section called "appSettings" and include all the keys you need from your app.config file. For example, I added a key MyTime with value 300000:

<appSettings>   
    <add key="MyTime" value="300000" />
</appSettings>

Once this is done, you can easily access the desired value by its key in a coded step like this:

//Get the custom config file
Configuration config = ConfigurationManager.OpenExeConfiguration(@"C:\Users\peykov\Desktop\MyXml.xml");
 
//Initializes a new instance of the ParamsManager class
ParamsManager manager = new ParamsManager();
 
//Load params from the XML file
manager.LoadFromXmlFile(@"C:\Users\peykov\Desktop\MyXml.xml");
 
//Get the custom Key value
var myConfigSettingsValue = this.ExecutionContext.Params["MyTime"];
Assert.IsNotNull(myConfigSettingsValue);
 
Log.WriteLine(myConfigSettingsValue);

Please give it a try and let me know if you need further assistance on this.

Kind regards,
Plamen
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Justin
Top achievements
Rank 2
answered on 14 May 2013, 06:15 PM
There are some problems with your proposed solution:
1) The legacy DLL expects a particular xml node structure within the app.config
2) I am not accessing the keys within MY dll (the legacy DLL is accessing the app.config)
3) I am using standalone Test Studio (not Visual Studio plugin). How should I add the app.config in this case?

I have attached a zip containing a very basic sample of what I am attempting to do. Within the zip are:
1) A Visual Studio project containing
     a) A "legacy" class library
     b) A console application with an app.config that adheres to the legacy code's expectations and will run as expected
2) A telerik test studio project which has a coded step that executes the legacy code provided and fails. Even if I manually place a ProjectWithLegacyDLL.dll.config in my test studio project bin, it is failing.

Let me know if the attached zip helps clarify my problem.
0
Plamen
Telerik team
answered on 16 May 2013, 08:08 AM
Hello Justin,

Thanks for providing the sample project. The default app.config file that Test Studio uses is ArtOfTest.Runner.exe.config. This file is located in the Test Studio's Bin folder.

  • C:\Program Files (x86)\Telerik\Test Studio\Bin

In order to make this to work, you can simply replace the content of our config file with the content of your app.config. See this video for a quick demonstration and let me know if you need further assistance on this.

Please keep in mind that next time you decide to upgrade Test Studio to a newer version, our installer will probably restore the default ArtOfTest.Runner.exe.config settings, so you should always keep a copy of that file stored somewhere on your machine.    

Regards,
Plamen
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Justin
Top achievements
Rank 2
answered on 21 May 2013, 02:55 PM
Thanks, the video was useful.

Is there any way I would be able to configure this per project? Although I can modify the ArtOfTest.Runner.exe.config it would apply to all of my projects (essentially the same as if I modified my machine.config). The problem with that is that I may wish to test different projects that want to use different app-level configurations.

For example:

Project 1
<specialInfo someDirectory="../../SpecialInfoConfig">
    <childFile someFile="DBConnections.xml"/>
</specialInfo>


Project 2
<specialInfo someDirectory="../../Project2Config">
    <childFile someFile="Project2DBConnections.xml"/>
    <childFile someFile="OtherProject2File.xml"/>
</specialInfo>
0
Accepted
Plamen
Telerik team
answered on 23 May 2013, 11:26 AM
Hi Justin,

Unfortunately there is no way to configure this per project. Our ArtOfTest runner by design can only read from single config file.

Regards,
Plamen
Telerik
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Justin
Top achievements
Rank 2
answered on 23 May 2013, 03:20 PM
Alright, thanks for looking into it. I will see if I can find some means of working around this limitation.
Tags
General Discussions
Asked by
Justin
Top achievements
Rank 2
Answers by
Plamen
Telerik team
Justin
Top achievements
Rank 2
Share this question
or