In the world of QA engineering and test automation, teams are constantly under pressure to deliver faster, more stable, and more maintainable automated tests. Desktop applications, especially legacy or enterprise apps, add another layer of complexity because of dynamic UI components, changing object properties, and multiple user workflows. This is where TestComplete, combined with the Behavior-Driven Development (BDD) approach, becomes a powerful advantage. As you’ll learn throughout this TestComplete Tutorial, BDD focuses on describing software behaviors in simple, human-readable language. Instead of writing tests that only engineers understand, teams express requirements using natural language structures defined by Gherkin syntax (Given–When–Then). This creates a shared understanding between developers, testers, SMEs, and business stakeholders.
TestComplete enhances this process by supporting full BDD workflows:
- Creating Gherkin feature files
- Generating step definitions
- Linking them to automated scripts
- Running end-to-end desktop automation tests
This TestComplete tutorial walks you through the complete process from setting up your project for BDD to creating feature files, implementing step definitions, using Name Mapping, and viewing execution reports. Whether you’re a QA engineer, automation tester, or product team lead, this guide will help you understand not only the “how” but also the “why” behind using TestComplete for BDD desktop automation.
By the end of this guide, you’ll be able to:
- Understand the BDD workflow inside TestComplete
- Configure TestComplete to support feature files
- Use Name Mapping and Aliases for stable element identification
- Write and automate Gherkin scenarios
- Launch and validate desktop apps like Notepad
- Execute BDD scenarios and interpret results
- Implement best practices for long-term test maintenance
Related Blogs
What Is BDD? (Behavior-Driven Development)
BDD is a collaborative development approach that defines software behavior using Gherkin, a natural language format that is readable by both technical and non-technical stakeholders. It focuses on what the system should do, not how it should be implemented. Instead of diving into functions, classes, or code-level details, BDD describes behaviors from the end user’s perspective.
Why BDD Works Well for Desktop Automation
- Promotes shared understanding across the team
- Reduces ambiguity in requirements
- Encourages writing tests that mimic real user actions
- Supports test-first approaches (similar to TDD but more collaborative)
Traditional testing starts with code or UI elements. BDD starts with behavior.
For example:
Given the user launches Notepad,
When they type text,
Then the text should appear in the editor.
TestComplete Tutorial: Step-by-Step Guide to Implementing BDD for Desktop Apps
Creating a new project
To start using the BDD approach in TestComplete, you first need to create a project that supports Gherkin-based scenarios. As explained in this TestComplete Tutorial, follow the steps below to create a project with a BDD approach.
After clicking “New Project,” a dialog box will appear where you need to:
- Enter the Project Name.
- Specify the Project Location.
- Choose the Scripting Language for your tests.
Next, select the options for your project:
- Tested Application – Specify the application you want to test.
- BDD Files – Enable Gherkin-based feature files for BDD scenarios.
- Click ‘Next’ button
In the next step, choose whether you want to:
- Import an existing BDD file from another project,
- Import BDD files from your local system, or
- Create a new BDD file from scratch.
After selecting the appropriate option, click Next to continue.
In the following step, you are given another decision point, so you must choose whether you prefer to:
- Import an existing feature file, or
- Create a new one from scratch.
If your intention is to create a new feature file, you should specifically select the option labeled Create a new feature file.
Add the application path for the app you want to test.
This critical action will automatically include your chosen application in the Tested Applications list. As a result, it becomes remarkably easy to launch, close, and interact with the application directly from TestComplete without the need to hardcode the application path anywhere in your scripts.
After selecting the application path, choose the Working Directory.
This selected directory will consequently serve as the base location for all your projects. files and resources. Therefore, it ensures that TestComplete can easily and reliably access every necessary asset during test execution.
Once you’ve completed the above steps, TestComplete will automatically create a feature file with basic Gherkin steps.
This generated file fundamentally serves as the essential starting point for authoring your BDD scenarios using the standard Gherkin syntax.
In this TestComplete Tutorial, write your Gherkin steps in the feature file and then generate the Step Definitions.
Following this, TestComplete will automatically create a dedicated Step Definitions file. Importantly, this file contains the script templates for each individual step within your scenarios. Afterwards, you can proceed to implement the specific automation logic for these steps using your chosen scripting language.
Launching Notepad Using TestedApps in TestComplete
Once you have successfully added the application path to the Tested Applications list, you can then effortlessly launch it within your scripts without any hardcoded path. This effective approach allows you to capably manage multiple applications and launch each one simply by using the names displayed in the TestedApps list.
Adding multiple applications in TestApps
Begin by selecting the specific application type. Subsequently, you must add the precise application path and then click Finish. As a final result, the application will be successfully added to the Tested Applications list.
Select the application type
Add the application path and click Finish.
The application will be added to the Tested Applications list
What is Name Mapping in TestComplete?
Name Mapping is a feature in TestComplete that allows you to create logical names for UI objects in your application. Instead of relying on dynamic or complex properties (like long XPath or changing IDs), you assign a stable, readable name to each object. This TestComplete Tutorial highlights how Name Mapping makes your tests easier to maintain, more readable, and far more reliable over time.
Why is Name Mapping Used?
- Readability: Logical names like LoginButton or UsernameField are easier to understand than raw property values.
- Maintainability: If an object’s property changes, you only update it in Name Mapping—not in every test script.
Pros of Using Name Mapping
- Reduces script complexity by avoiding hardcoded selectors.
- Improves test reliability when dealing with dynamic UI elements.
- Centralized object management update once, apply everywhere.
Adding objects in name mapping using add object
Adding Objects to Name Mapping
You can add objects by utilizing the Add Object option, so follow these instructions:
- First, open the Name Mapping editor within TestComplete.
- Then, click on the Add Object button.
- Finally, save the completed mapping.
To select the UI element, use the integrated Object Spy tool on your running application.
TestComplete provides two distinct options for naming your mapped objects, which are:
- Automatic Naming – Here, TestComplete assigns a default name based directly on the object’s inherent properties.
- Manual Naming – In this case, you can assign a custom name based entirely on your specific requirements or the functional role of the window.
For this tutorial, we will use manual naming to achieve superior clarity and greater control over how objects are referenced later in scripts.
Manual Naming and Object Tree in Name Mapping
When you choose manual naming in TestComplete, you’ll see the object tree representing your application’s hierarchy. For example, if you want to map the editor area in Notepad, you first capture it using Object Spy.
Steps:
- Start by naming the top-level window (e.g., Notepad).
- Then, name each child object step by step, following the tree structure:
- Think of it like a tree:
- Root → Main Window (Notepad)
- Branches → Child Windows (e.g., Menu Bar, Dialogs)
- Leaves → Controls (e.g., Text Editor, Buttons)
- Once all objects are named, you can reference them in your scripts using these logical names instead of raw properties.
Once you’ve completed the Name Mapping process, you will see the mapped window listed in the Name Mapping editor.
Consequently, you can now reference this window in your scripts by using the logical name you assigned, rather than relying on unstable raw properties.
Using Aliases for Simplified References
TestComplete allows you to further simplify object references by creating aliases. Instead of navigating the entire object tree repeatedly, you can:
- Drag and drop objects directly from the Mapped Objects section into the dedicated Aliases window.
- Then, assign meaningful alias names based on your specific needs.
This practice helps you in two key ways: it lets you access objects directly without long hierarchical references, and it makes your scripts cleaner and significantly easier to maintain.
// Using alias instead of full hierarchy Aliases.notepad.Edit.Keys(“Enter your text here ”);
Tip: Add aliases for frequently used objects to speed up scripting and improve readability.
Entering Text in Notepad
// ----------- Without adding namemapping ----------------------
//var Np=Sys.Process("notepad").Window("Notepad", "*", 1).Window("Edit", "", 1)
//Np.Keys(TextToEnter)
// -----------Using Namemapping ---------------
Aliases.notepad.Edit.Keys(TextToEnter);
Validating the entered text in notepad
// Validate the entered text
var actualText = Aliases.notepad.Edit.wText;
if (actualText === TextToEnter) {
Log.Message("Validation Passed: Text entered correctly."+actualText);
} else {
Log.Error("Validation Failed: Expected '" + textToEnter + "' but found '" + actualText + "'");
}
Executing Test Scenarios in TestComplete
To run your BDD scenarios, execute the following procedure:
- Right-click the feature file within your project tree.
- Select the Run option from the context menu.
- At this point, you can choose to either:
- Run all scenarios contained in the feature file, or
- Run a single scenario based on your immediate requirement.
This inherent flexibility allows you to test specific functionality without having to execute the entire test suite.
Viewing Test Results After Execution
After executing your BDD scenarios, you can immediately view the detailed results under the Project Logs section in TestComplete. The comprehensive log provides the following essential information:
- The pass/fail status was recorded for each scenario.
- Specific failure reasons for any steps that did not pass.
- Warnings, which are displayed in yellow, are displayed for steps that were executed but with potential issues.
- Failed steps are highlighted in red, and passed steps are highlighted in green.
- Additionally, a summary is presented, showing:
- The total number of test cases executed.
- The exact count of how many passed, failed, or contained warnings.
This visual feedback is instrumental, as it helps you rapidly identify issues and systematically improve your test scripts.
Accessing Detailed Test Step View in Reports
After execution, you can drill down into the results for more granular detail by following these steps:
- First, navigate to the Reports tab.
- Then, click on the specific scenario you wish to review in detail.
- As a result, you will see a complete step-by-step breakdown of all actions executed during the test, where:
- Each step clearly shows its status (Pass, Fail, Warning).
- Failure reasons and accompanying error messages are displayed explicitly for failed steps.
- Color coding is applied as follows:
- ✅ Green indicates Passed steps
- ❌ Red indicates failed steps
- ⚠️ Yellow indicates warnings.
Comparison Table: Manual vs Automatic Name Mapping
| S. No | Text in 1st column | Text in 2nd column |
|---|---|---|
| 1 | Setup Speed | Fast / Slower |
| 2 | Readability | Low / High |
| 3 | Flexibility | Rename later / Full control |
| 4 | Best For | Quick tests / Long-term projects |
Real-Life Example: Why Name Mapping Matters
Imagine you’re automating a complex desktop application used by 500+ internal users. UI elements constantly change due to updates. If you rely on raw selectors, your test scripts will break every release.
With Name Mapping:
- Your scripts remain stable
- You only update the mapping once
- Testers avoid modifying dozens of scripts
- Maintenance time drops drastically
For a company shipping weekly builds, this can save 100+ engineering hours per month.
Conclusion
BDD combined with TestComplete provides a structured, maintainable, and highly collaborative approach to automating desktop applications. From setting up feature files to mapping UI objects, creating step definitions, running scenarios, and analyzing detailed reports, TestComplete’s workflow is ideal for teams looking to scale and stabilize their test automationBDD combined with TestComplete provides a structured, maintainable, and highly collaborative approach to automating desktop applications. From setting up feature files to mapping UI objects, creating step definitions, running scenarios, and analyzing detailed reports, TestComplete’s workflow is ideal for teams looking to scale and stabilize their test automation. As highlighted throughout this TestComplete Tutorial, these capabilities help QA teams build smarter, more reliable, and future-ready automation frameworks that support continuous delivery and long-term quality goals.
Frequently Asked Questions
-
What is TestComplete used for?
TestComplete is a functional test automation tool used for UI testing of desktop, web, and mobile applications. It supports multiple scripting languages, BDD (Gherkin feature files), keyword-driven testing, and advanced UI object recognition through Name Mapping.
-
Can TestComplete be used for BDD automation?
Yes. TestComplete supports the Behavior-Driven Development (BDD) approach using Gherkin feature files. You can write scenarios in plain English (Given-When-Then), generate step definitions, and automate them using TestComplete scripts.
-
How do I create Gherkin feature files in TestComplete?
You can create a feature file during project setup or add one manually under the Scenarios section. TestComplete automatically recognizes the Gherkin format and allows you to generate step definitions from the feature file.
-
What are step definitions in TestComplete?
Step definitions are code functions generated from Gherkin steps (Given, When, Then). They contain the actual automation logic. TestComplete can auto-generate these functions based on the feature file and lets you implement actions such as launching apps, entering text, clicking controls, or validating results.
-
How does Name Mapping help in TestComplete?
Name Mapping creates stable, logical names for UI elements, such as Aliases.notepad.Edit. This avoids flaky tests caused by changing object properties and makes scripts more readable, maintainable, and scalable across large test suites.
-
Is Name Mapping required for BDD tests in TestComplete?
While not mandatory, Name Mapping is highly recommended. It significantly improves reliability by ensuring that UI objects are consistently recognized, even when internal attributes change.
Ready to streamline your desktop automation with BDD and TestComplete? Our experts can help you build faster, more reliable test suites.
Get Expert Help











Comments(0)