Functional Test

Functional testing is a black-box testing method to check the functionalities of a system at a high level without thinking about the internal code. Normally, the company uses this level of testing to check the expected functionalities in different demos depending on the team.

The idea is to have the most complete demo possible to check each component, event, and functionalities in general and run all tests created or the tests with the most level of value (smoke test) against each change in the code. In this way, it is easier to check if some of the functionalities change or fail due to the change implemented.

The process to follow at this level is the following:

  1. Design the scenarios or test cases with their steps.

  2. Validate if the test cases are correct and work as expected.

  3. Create in Azure DevOps the test cases designed and validated in the previous steps.

Not all test cases can be automated, and because of it, it is necessary to have the test cases registered in some place, like Azure DevOps, to have the possibility to apply those tests in a manual way. However, other test cases can be automated, and consequently, some standards need to be followed.

The established standards to create automated functional tests in the company are the following:

  • Any project related to functional testing must use the entire library created by the Quality Mate Team. (See QualityMate Documentation)

  • It is important to follow the good practices to use the Quality Mate library, for example, use “validate” instead of "assert", not create extra classes to use functionalities that already exist in Quality Mate, etc.

  • The structure of the project should be one folder to include the page objects and another to include the test cases. Any other folder is valid, but it is necessary to follow the basic structure mentioned before.

  • Each page object should represent only one window, view, form, or page of the application and the components inside them to maintain the order and logic of the structure.

  • Each test must document in the log each significant group of steps. Using the next code provided by QualityMate:

controller.log("Explain the step to perform");
  • To avoid extra code and improve the performance in the tests, it is necessary to use the ID of the component to automate the name of any control. If the control does not have an ID, it is valid to use the selector, the first option to use is the CSS selector and XPath Selector as the last option.

  • Follow the basic good practices to create any test case. (See Good practices).

  • Document the test case using the basic tags and summaries. (See Test Documentation)

Example following the standards

The next examples are a reinterpretation with the standards of the example provided by QualityMate. Here is the original example.

Example Page Object

// <copyright file="ExamplePage.cs" company="Mobilize.Net">
//        Copyright (C) Mobilize.Net info@mobilize.net - All Rights Reserved
//
//        This file is part of the Mobilize Frameworks, which is
//        proprietary and confidential.
//
//        NOTICE:  All information contained herein is, and remains
//        the property of Mobilize.Net Corporation.
//        The intellectual and technical concepts contained herein are
//        proprietary to Mobilize.Net Corporation and may be covered
//        by U.S. Patents, and are protected by trade secret or copyright law.
//        Dissemination of this information or reproduction of this material
//        is strictly forbidden unless prior written permission is obtained
//        from Mobilize.Net Corporation.
// </copyright>

namespace Mobilize.FunctionalTest.Example
{
    using Mobilize.QualityMate.Automation.Entities;
    using Mobilize.QualityMate.ControlInterfaces;

    /// <summary>
    /// PageObject that describes the UI controls of an application.
    /// </summary>
    public class ExamplePage : PageObject
    {
        /// <summary>
        /// Describes a TextBox control presented on the Application.
        /// </summary>
        public ITextBox textBox1 { get; set; }

        /// <summary>
        /// Describes a Button control presented on the Application.
        /// </summary>
        public IButton button1 { get; set; }

        /// <summary>
        /// Describes a Label control presented on the Application.
        /// </summary>
        public ILabel label1 { get; set; }
    }
}

Example Test Case

// <copyright file="FunctionalTestExample.cs" company="Mobilize.Net">
//        Copyright (C) Mobilize.Net info@mobilize.net - All Rights Reserved
//
//        This file is part of the Mobilize Frameworks, which is
//        proprietary and confidential.
//
//        NOTICE:  All information contained herein is, and remains
//        the property of Mobilize.Net Corporation.
//        The intellectual and technical concepts contained herein are
//        proprietary to Mobilize.Net Corporation and may be covered
//        by U.S. Patents, and are protected by trade secret or copyright law.
//        Dissemination of this information or reproduction of this material
//        is strictly forbidden unless prior written permission is obtained
//        from Mobilize.Net Corporation.
// </copyright>

namespace Mobilize.FunctionalTest.Example
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using Mobilize.QualityMate.Automation.Extensions;
    using Mobilize.QualityMate.BDD.Annotations;
    using Mobilize.QualityMate.UiTesting.MsTest;

    [TestClass]
    [Feature("Description of the feature to test")]
    public class FunctionalTestExample : UiTest
    {
        /// <summary>
        /// Document in a better way the scenario to test.
        /// <seealso href="https://theLinkOfTheTestCaseInAzureDevOps"/>
        /// </summary>
        [TestCategory("Functional Test")]
        [Scenario("Describe an example to follow the standars")]
        public void HelloWorld()
        {
            this.Execute(controller => {
                ExamplePage examplePage = controller.GetPageObject<ExamplePage>();

                controller.Log("1 - Write message 'Hello World' in textbox");
                examplePage.textBox1.Text = "Hello World";

                controller.Log("2 - Validate the message after click"); 
                examplePage.button1.Click();
                examplePage.label1.Validate(label => label.Text.Equals("Hello World")); 
            });
        }
    }
}

Notes

  • It is valid to add any other NuGet or dependency in the project depending on the necessity.

  • Some teams create a base class with common steps to reuse in the other test cases and avoid repeated code.

  • Related to the last point, sometimes it is better to write methods with the steps in the test class and use those methods in the "Execute" in order to improve the readability and maintainability.

Last updated