Archive for the ‘Software testing and quality’ Category.

The TestApi v0.4 has shipped

The TestApi v0.4 has shipped! You can download the latest bits at http://codeplex.com/testapi. Some of the updates
• An improved Combinatorial Variation Generation API – we now support parameter value weights and tags (for “negative” variations);
• A new Memory Leak Detection API – allowing capture, comparison, and serialization/de-serialization of memory snapshots of a running process;
• A new Object Comparison API – allowing comparison of arbitrary .NET objects using arbitrary object comparison strategies;
• A new Text String Generation API – allowing generation of random strings, interesting from the testing point of view;
• Various documentation improvements and sample additions.

WPF Application Quality Guide v0.5 has been released

WPF Application Quality Guide v0.5 has been released today at the WindowsClient.NET with new topics and updates.

This release includes several new additions and updates:
1. Suggested Roadmap – updated to include new topics based on different persona
2. Performance and Scalability Testing – updated with a few new resources
3. Integration and Scenario Testing – a new article outlines the strategies and the steps to take in Integration and Scenario testing.
4. TestApi (Tools) – updated with summary of the new APIs from TetsApi v0.2 as well as sample usages.
5. Tools – various new additions and updates to commonly used tools.
6. A1 Building a WPF Application Test Suite by Using VSTS, NUnit, or xUnit – a new article summarized the common unit testing frameworks including sample test code and key resources.
7. A4 Considerations for WPF Browser Applications – a new valuable write-up with common considerations in XBap apps.

The full online version can be found here.
Online
Word

UI automation with accessibility object and win 32 API

In my earlier blogs (Fun with UIAutomation and calc, Fun with UIAutomation and calc 2 (event handling)) I have been talking about how to user uiautomation in .NET. Now it time to dig down bellow uiautomation and go directly to the source WIN 32 API. I have tried to translate the first calculator project to use win 32 API and accessibility object instead. The first thing that we need to-do is to create DllImport statement for user32.dll used for handling more or less all windows UI and oleacc.dll used for accessing the accessibility object. You will find my complete solution in the end of the blog.

An example of DllImport is EnumChildWindows that gives use the possibility to get all child windows to a specific window.

[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool EnumChildWindows(IntPtr parentHandle, Win32Callback callback, IntPtr lParam);

Continue reading ‘UI automation with accessibility object and win 32 API’ »

How to determine if we are running on 64 or 32 bit?

In my work I need to be able to pick different files depending on if I run in 64 bit or 32 bit system. The first thing I did try was to use the size of IntPtr which is 4 for 32 bit and 8 for 64 bit. But since I was using the visual studio unit test framework it did not work that god. The unit test framework run in a 32 bit process but the application I’m testing is running in 64 bit, so decided to use P/Invoke to call GetNativeSystemInfo.

The structure that you get is according to

[StructLayout(LayoutKind.Sequential)]
private struct SystemInfoNative
{
    internal ushort ProcessorArchitecture;
    internal ushort Reserved;
    internal uint PageSize;
    internal IntPtr MinimumApplicationAddress;
    internal IntPtr MaximumApplicationAddress;
    internal IntPtr ActiveProcessorMask;
    internal uint NumberOfProcessors;
    internal uint ProcessorType;
    internal uint AllocationGranularity;
    internal ushort ProcessorLevel;
    internal ushort ProcessorRevision;
}

Out from this you can check the processor architecture.

And the complete source code
Continue reading ‘How to determine if we are running on 64 or 32 bit?’ »

Introducing WPF Application Quality Guide v.0.4

WPF Application Quality Guide v0.4 has been released today at the WindowsClient.NET with new topics and updates.

This release includes several new topics and updates:
1. Suggested Roadmap – updated to include new topics
2. Data-Driven Testing – a new article about the data-driven testing practice.
3. Globalization and Localization Testing – updated w/ more details including creating localizable UI layouts in WPF and approaches to localizing WPF applications.
4. Stability and Stress Testing – a new article about stress testing principles, best practices, and useful resources.
5. Accessibility Testing – a new article about accessibility considerations, best practices and key resources.
6. Tools / TestAPI – a brief intro about the newly released TestAPIs.

The full online version can be found here.

Fun with UIAutomation and calc 2 (event handling)

Last week, I wrote about UIAutomation and calc. Now it’s time to revisit or little example program and replace the automatic start of calc and replace it a method that will wait for any calc to start and take control over that session. To abstract away the waiting code, I did create a new class called WindowOpenWaiter. Let’s take a look how we can use or new class. The full code to this blog can be found in the bottom.

The first thing we need to-do is to create a new instance of WindowOpenWaiter and give the title to the window that it should look for. Next thing is to call the wait methods with a timeout time in mille seconds so that we will not wait forever. The last thing we do is to get the element that the waiter has found for us and save it in some variable.

AutomationElement calc = null;
using (WindowOpenWaiter waiter = new WindowOpenWaiter("Calculator"))
{
    try
    {
        waiter.Wait(1000 * 10);
    }
    catch (TimeoutException e)
    {
        Console.WriteLine(e.Message);
        return;
    }
 
    calc = waiter.Element;
}

Continue reading ‘Fun with UIAutomation and calc 2 (event handling)’ »

Fun with UIAutomation and calc

Last night I got a cool idea how to show some basic ideas of UIAutomation. I did decide to-do a UIAutomation example with calc as my test subject. The idea is to give a mathematical expression to the program, which will then use calc to solve the problem and show you the result. The main thing is to show how UIAutomation is working and not to calculate.

The first thing that we need is a method that can find an AutomationElement for us. An AutomationElement is anything that you can see on the screen as buttons and input fields. The method take a root AutomationElement that define where to start to search, a name and a class name for the object that we are looking for. We then create two property conditions based on the name and class name. These two conditions are then combined in an AndCondition. We also have OrCondition and NotCondition to use. The last thing we do is to search for the first AutomationElement that match the condition.

private static AutomationElement GetElement(AutomationElement root, string name, string className)
{
    PropertyCondition condName = new PropertyCondition(AutomationElement.NameProperty, name);
    PropertyCondition condClassName = new PropertyCondition(AutomationElement.ClassNameProperty, className);
    AndCondition cond = new AndCondition(condName, condClassName);
    return root.FindFirst(TreeScope.Descendants, cond);
}

Next method that we need is one that can return a invoke pattern. Invoke pattern is used for example to click on a button. This will be used to be able to click on the different buttons in calc

private static InvokePattern GetInvokePattern(AutomationElement element)
{
    return element.GetCurrentPattern(InvokePattern.Pattern) as InvokePattern;
}

Continue reading ‘Fun with UIAutomation and calc’ »