June 2009 - Posts

How to write a custom log in LTAF June release?
Wednesday, June 10, 2009 3:35 PM

If you want to write a custom log while running your test, the June 2009 release of LTAF now provides an easier way to set that up. The DriverPage gives access to a TestcaseExecutor object that exposes several lifecycle events

Here is a code snippet that shows how to write your own log (MyCustomLog.txt) by attaching to the proper events to gather information while the tests are executing.

private StringBuilder _log;
private string _logPath;

protected override void RunTestCases()
{
    // if user checked the Write Log To Disk checkbox
    if (this.WriteLogToDiskCheckBox.Checked)
    {
        // attach event handlers to write my custom log
        this.TestcaseExecutor.TestcaseExecuted += 
            new EventHandler<TestcaseExecutionEventArgs>(TestcaseExecutor_TestcaseExecuted);
        
        this.TestcaseExecutor.TestRunFinished += 
            new EventHandler<TestRunFinishedEventArgs>(TestcaseExecutor_TestRunFinished);

        this.TestcaseExecutor.TestRunStarted += new EventHandler(TestcaseExecutor_TestRunStarted);

        _logPath = System.IO.Path.Combine(Server.MapPath(""), "MyCustomLog.txt");
        _log = new StringBuilder();
    }
    
    base.RunTestCases();
}

void TestcaseExecutor_TestRunStarted(object sender, EventArgs e)
{
    _log.AppendLine("Test Run Started.");
}

void TestcaseExecutor_TestcaseExecuted(object sender, TestcaseExecutionEventArgs e)
{
    _log.AppendLine(String.Format(
        "Finished running test '{0}'. Status='{1}'", 
        e.WebTestName, 
        e.Passed));
}

void TestcaseExecutor_TestRunFinished(object sender, TestRunFinishedEventArgs e)
{   
    _log.AppendLine("Test Run Finished.");
    
    // make sure that you have write access to the test folder
    System.IO.File.WriteAllText(_logPath, _log.ToString());
}

The "MyCustomLog.txt" file will be written into the same folder where the DriverPage.aspx exists.

Federico Silva Armas
SDET, ASP.NET QA Team

by farmas | with no comments
Filed under: ,
What's new in LTAF June release?
Wednesday, June 10, 2009 3:34 PM

The June 2009 release of the Lightweight Test Automation Framework is out on CodePlex. Here is a small write up of the new features available.

Automation of frames

Now tests can automate pages that contain framesets and iFrames. For example:

[WebTestMethod]
    public void Frame()
    {
        HtmlPage page = new HtmlPage("TestFrameSet.htm");

        // get top frame
        HtmlPage frame = page.GetFramePage("topFrame");

        // verify title of frame
        Assert.AreEqual("This is the top frame", frame.Elements.Find("h1", 0).GetInnerText());
    }

 

Write to the test console

This is an experimental feature that is useful to debug tests. You can now write messages from your test into the test console that appears in the driver page. For example:

[WebTestMethod]
    public void PopupPageWithIndex()
    {
        // Navigate to the frameset
        HtmlPage page = new HtmlPage("TestFrameSet.htm");

        //get the top frame
        WebTestConsole.Write("Get the top frame");
        HtmlPage frame = page.GetFramePage("topFrame");

        // click on the button that opens a new page
        WebTestConsole.Write("Click the openwindow button");
        frame.Elements.Find("OpenWindow").Click();

    ...

When run, this test will output traces into the console UI:

image

 

Hide the test console

New option in the UI allows user to hide the test console. This is useful for long running test suites, to prevent the browser from maintain a grown list of commands.

image

 

Quickly verify page is rendering an asp.net error

New helper method in HtmlPage makes it easy to quickly verify if a asp.net error page is being rendered. This is useful to immediately stop the test if an error has occurred, instead of waiting for a timeout. For example:

[WebTestMethod]
    public void VerifyTheAspNetErrorPage()
    {
        HtmlPage p = new HtmlPage("PageWithError.aspx");
        bool pageFail = p.IsServerError();
        Assert.IsFalse(pageFail);

        ...
    }

 

Exposed test run lifecycle events

Users can now register handlers in the DriverPage.aspx to several life cycle events. This is useful, for example, to generate a custom log:

protected override void RunTestCases()
   {
       // if user checked the Write Log To Disk checkbox
       if (this.WriteLogToDiskCheckBox.Checked)
       {
           // attach event handlers to write my custom log
           this.TestcaseExecutor.TestcaseExecuted += 
               new EventHandler<TestcaseExecutionEventArgs>(TestcaseExecutor_TestcaseExecuted);
           
           this.TestcaseExecutor.TestRunFinished += 
               new EventHandler<TestRunFinishedEventArgs>(TestcaseExecutor_TestRunFinished);    
       }
       
       base.RunTestCases();
   }

 

Additional Resources

 

Federico Silva Armas
SDET, ASP.NET QA Team

by farmas | 2 comment(s)
Filed under: ,
CodingQA Podcast Episode 9
Saturday, June 06, 2009 12:09 PM

Download: Episode 9
Streaming: Episode 9

In this show Matthew and Federico talk about what the ASP.NET QA team does to prepare for a release. Taking into account the recent release of ASP.NET 4 Beta 1, they’ll go over several of the "exit criteria" that the product must meet before delivery to the public.

News

  • Lightweight Test Automation Framework June Release

Sign off on a release

  • Difference between Quality Gates and Exit Criteria
  • Accessibility. Mainly manual tests to validate feature conforms to accessibility standards.
  • Code Coverage. Metric used to identify problematic development areas.
  • Stress. Specialized automated long running tests to spot memory leaks and other stress problems.
  • Localization. Verification that the product can be correctly localized to several languages.
  • Test Passes. Functional verification of the product across many platform combinations.
  • Zero Active Bugs. Series of step down goals to drive feature crews to finish development.
by farmas | with no comments
Filed under: ,
CodingQA Podcast Episode 8
Saturday, June 06, 2009 12:06 PM

Download: Episode 8
Streaming: Episode 8

This show is an open discussion about what testing means. Federico and Matthew share their opinions around the meaning of "testing", "quality" and the role of a QA team. They don't always agree but each brings something unique to the table on topics so basic yet somewhat mysterious in the testing discipline.

News

Topics of Discussion

  • What is the role of QA?
  • What is testing?
  • What is quality?
  • Should quality be measurable?
  • What is risk?
  • What is the difference between Dev and Test?
by farmas | 3 comment(s)
Filed under: ,
More Posts