Course Content
Introduction to QA Automation Testing
Introduction to QA Automation Testing
Introduction to Test Automation Frameworks
In the context of Software Development & Testing, a Test Automation Framework, also referred to as an Automation Testing Framework, is a set of tools and methods grouped together in the form of a package. These tools are designed to help us write and execute various kinds of tests using a programming language.
A Testing Framework provides us with a structured environment for testing our application. This "environment" consists of various tools and scripts which facilitate us in the testing process. A testing environment may consist of the following elements:
- Test Scripts: These are the scripts containing the test cases, which we write to test our application. These scripts are written using the functions or methods which are often provided by the Testing Framework;
- Test Data: This refers to the input data that is used in the test cases. If this data is trivial, then it can be embedded directly into the Test Scripts, otherwise, larger volumes of Test Data is typically stored in separate files or a database;
- Test Execution: This refers to the mechanism for automatically detecting and executing all the Test Scripts present in the project. In JavaScript, most testing frameworks have the functionality of automatically detecting the test scripts. For-example, when a tester executes the test command in the console, the framework may look for all the files with names ending in ".test.js" and execute them as a Test Script;
- Assertion Methods: Methods that help in verifying the correctness of the outputs. These methods behave similar to if-conditions but are specifically designed for testing;
Test Automation Frameworks have many additional helper tools which make it easier for us to test applications, therefore, it is always a good practice to utilize a proper Test Automation Framework for testing purposes.
Since we are exploring Test Automation using JavaScript, therefore, it is imperative for us to look at the frameworks made for JavaScript. Two of the most popular Test Automation Frameworks in JavaScript are Mocha and Jest.
☕ MochaJS
MochaJS (☕) is a flexible and customizable framework which focuses on customizability. The important point to note about Mocha is that it does not come with some of the testing tools integrated within itself, rather, external tools and libraries are often integrated with it to extend its functionality. For-example, Mocha doesn’t come with methods for performing assertions, therefore, we typically utilize an external assertion library like ChaiJS along with it. If you've looked into software testing before, you likely came across the phrase 'Mocha & Chai.' These two technologies are frequently used together and have become a standard pairing.
Jest
Jest on the other hand, is a full-fledged standalone testing framework, which comes with all the required tools. It is designed to work out of the box with minimal configuration, and hence, it is simpler to use. Jest was developed by Facebook, primarily to be used for testing React applications, however, it developed to become a fairly robust framework, and hence it can be used for testing any kind of JavaScript application.
Due to its ease of use, we will be utilizing Jest for testing purposes. It is important to note that the majority of the terms & concepts which we learn in this section will be transferable to testing frameworks in other languages, with the obvious difference being in the syntax.
Thanks for your feedback!