Test Deployment Directory

4 posts, 0 answers
  1. Gavin
    Gavin avatar
    6 posts
    Member since:
    Jan 2013

    Posted 25 Feb 2013 Link to this post

    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?
  2. Steven
    Steven avatar
    2 posts
    Member since:
    Jan 2013

    Posted 26 Feb 2013 Link to this post

    check into \Users\[username]\Documents\Test Studio Projects\[project name]\Results
    you'll find text files and screenshots there that should help you.

    -Steven

  3. Gavin
    Gavin avatar
    6 posts
    Member since:
    Jan 2013

    Posted 26 Feb 2013 Link to this post

    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..



  4. Plamen
    Admin
    Plamen avatar
    8 posts

    Posted 01 Mar 2013 Link to this post

    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
Back to Top