C#Bot 2.3.0.0 Testing Framework Updates

Testing Framework Updates

Why are we changing the framework?

After talking to developers who use Codebots and seeing how they are using the testing framework, the following main problems were identified:

  • Not enough protected regions.
  • The code is not written in a way that is flexible.
  • The code is not written to a high quality.
  • Tests are not reliable.

These problems were mainly identified as being an issue within the Selenium framework.

Changes to Selenium framework

To address these problems, we re-wrote the core of the Selenium framework. Mostly, this meant breaking out some of the core files (such as the EntityDetailsSection), all files which contain repeated logic and little to no structure. These files, as well as others, have become junkyards of unusable code.
Many of the bot-written tests involve the use of the CRUD areas of the backend and the selenium code at the core of that has been re-written.

New Structure

As part of this change, the botwritten folders are being removed. Unfortunately, there is no concept of bot-written folders in a codebot’s file structure, only bot-written files.

As the testing framework is updated, all new work will be moved out of these folders. For now, the old code which remains in these folders won’t be deleted to give teams a chance to adapt to the changes as they are released.

Test Files

Updated test files are being moved out of the botwritten folder.

Every new *.feature file will also contain, as a hard rule, protected regions:

  • to alter the tags on the test file
  • to add more tests to the feature file, and
  • which wrap around each test in the feature file.

Step files

Updates steps files are being moved out of the botwritten folder.

Every new step definition file also contain, as a hard rule, a protected regions:

  • for adding extra imports,
  • to override or add class properties,
  • for wrapping the constructor,
  • for each step definition, and
  • to add extra step definitions.

View models

View models have gone through a lot of updates, with the focus on creating a good connections between what is contained in the client-side when a user is viewing and interacting with pages, to models of those pages and components. These models are used as the steps and should not contain assertions within them.

As part of the upgrade, many new, re-usable component models are included. These include:

  • Button Component Model
  • Text Field Component Model
  • Date/Time Picker Component Models
  • Checkbox Component Model
  • File Upload Component Model
  • Combobox Component Model

The idea is to create clean, high quality re-usable components to enable developers to quickly build out their own page object models. Component models should be used in place of using IWebElements directly.

Additionally, the CRUD List components have been modelled for each entity in a way that should be re-usable throughout the application. For each entity, this includes a:

  • Model for the Crud List.
  • Model for the create entity component.
  • Model for the edit entity component.
  • Model for the view entity component.

All new components and page models are being moved from /PageObjects/BotWritten to the /ViewModels folder. Into the subfolder /ViewModels/Pages if it is a page model or the /ViewModels/Components folder if it is a component model.

Every new component of page model file also contain, as a hard rule, protected regions:

  • for adding extra imports,
  • to override or add class properties,
  • wrapping the constructor,
  • for each class method, and
  • to add extra class methods.

Logic flow

Selenium tests now tightly follow this logic:

  1. Cucumber test files
  2. Step definitions to controls view models and make assertions.
  3. View models to interact with and control the selenium web driver.

Migration Plan

At the moment, all the old files and code is being kept in order to give developers time to move their work across to the new way of doing Selenium testing. No immediate action is required.

The first part of this process has been released in:

1 Like