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

Test Deployment Directory

3 Answers 108 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Gavin
Top achievements
Rank 1
Gavin asked on 25 Feb 2013, 10:24 PM
I'm familiar with the concept of a TestDeploymentDirectory which Visual Stuido uses when running a unit test or test list. 

Studio creates a structure like:
Test Results\
    User_Machine\
        \In
        \Out

All files needed to execute the test are copied to the Out folder, ie "Deployment Items"  Any screenshots, logs, etc generated by the test can be stored in the In folder for later analysis.  This structure makes solid logical sense to have a "folder per execution" to isolate the collateral and results.

Test Studio on the other hand doesn't seem to have this type of structure..  Logs goto c:\WebAiiLog and I see no "result" folder for a specific test list execution.  I would like to add code to my tests to output screenshots from my tests and it would be nice to somehow associate them with a test list execution.  Not just a bunch of files in c:\WebAiiLog

Is there any built in mechanism or best practice for this?

3 Answers, 1 is accepted

Sort by
0
Steven
Top achievements
Rank 1
answered on 26 Feb 2013, 07:14 PM
check into \Users\[username]\Documents\Test Studio Projects\[project name]\Results
you'll find text files and screenshots there that should help you.

-Steven

0
Gavin
Top achievements
Rank 1
answered on 26 Feb 2013, 07:26 PM
Ok, I see the Results folder and associated files...

Is there any way to get this folder from within the test execution context?
If I'm trying to manually take a screenshot with code like:

http://www.telerik.com/automated-testing-tools/community/forums/test-studio-express/automation-framework/getting-a-full-page-screenshot.aspx

Code from link:

                System.Drawing.Bitmap image = ActiveBrowser.Capture();
                if (image != null)
                {
                    var fileName = TypeName + "_" + DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss_ffff");
                    string testFilePath = System.IO.Path.Combine(Logger.TestRunScreenshotFilesFolder, fileName);
                    fileName = Path.ChangeExtension(testFilePath, ".png");
                    image.Save(fileName, ImageFormat.Png);
                    Logger.Error(String.Format("System wasn't working as expected. You can see screenshot of it here '{0}'", testFilePath));
                }
 
This is great, but several things don't work here...

  • What is Logger.TestRunScreenshotFilesFolder ?  This doesn't exist
  • Also, there are obviously some missing usings, ie..  System.IO, System.Drawing, etc...

I think this sample was written for the VS plugin version, not the studio version..

Either way, it would be nice to get the folder: \Users\[username]\Documents\Test Studio Projects\[project name]\Results

in code inside the test.. so that I can save the images to this folder, not some flat directory at the root of c:\

I could even use configuration to provide the base directory, but the last directory looks something like this:
"Test 130062992786787109_files" which I'd need to discover somehow.

Thanks..



0
Plamen
Telerik team
answered on 01 Mar 2013, 11:29 AM
Hello Gavin,

Please try the following code instead:
System.Drawing.Bitmap image = ActiveBrowser.Capture();
if (image != null)
{
    var fileName = "Image" + "_" + DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss_ffff");
    string testFilePath = System.IO.Path.Combine(ExecutionContext.DeploymentDirectory, "Results", fileName);
    Log.WriteLine(testFilePath);
    fileName = System.IO.Path.ChangeExtension(testFilePath, ".png");
    image.Save(fileName, ImageFormat.Png);              
}

In Test Studio you need to add assembly references to:
System.IO
System.Drawing

and the following using statements:
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;

All the best,
Plamen
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Tags
General Discussions
Asked by
Gavin
Top achievements
Rank 1
Answers by
Steven
Top achievements
Rank 1
Gavin
Top achievements
Rank 1
Plamen
Telerik team
Share this question
or