Introduction To Automated Testing

Olaoluwa
FAUN — Developer Community 🐾
5 min readJul 7, 2022

--

Hello 👋 and welcome, I’m undergoing a refinery process with The Startup Intern. During this process, I’ll be provided with study resources and tasks that will help solidify my learning. On successful completion of this process, I’ll be assigned to an organization as a backend developer intern. Kindly check out The Startup Intern on their website or on Twitter to know more about them and what they do. 🤝

Back To The Topic

As your application grows in size and complexity, the time required to test all the different bits and pieces increases exponentially. The workflow for manual testing is time-consuming, each execution path may take several minutes and possible human errors are usually unavoidable especially when an application contains hundreds to thousands of lines of code.
Automation helps to avoid these human errors in application testing as much as possible and executes checks faster.

. Testing cost: “As the graph above illustrates, there is an upfront cost to automated testing (as opposed to purely manual testing), but as the number of test cases and builds increases, the cost per test decreases”. -sorce: Art Trevethan for softwaremagazine.com.

An execution path is a possible flow of control of a program. It is the process by which a computer or virtual machine reads and acts on the instructions of a computer program.

In this article, I will be discussing:

What is Automated Testing?

Automated testing is the practice of writing scripts to test an application code and then running those tests (sequentially) in an automated fashion using a testing tool. It is a procedure that determines whether an application is operating correctly once it has satisfied all prerequisites before being released to production. Automated tests are repeatable and can be run easily in a few seconds each time changes are made. With automated testing, the source code will include the application/production code and the test scripts. All test scripts are written once and executed automatically at any time or when needed.

Benefits of Automated Testing

Automated testing helps to:

  • Prepare reusable tests by simplifying as much of the manual effort as possible into a set of scripts.
  • Reduce the cost of code revision.
  • Make test results more accurate by reducing possible human errors during manual testing.
  • Increase test coverage in less time with less team.
  • Detect/catch bugs at the early stage of development or before deploying with the aid of a good test report which in turn reduces the overall working hours and development costs.
  • Change the structure of code (refactor) with confidence without having to manually test other parts of the application that could have been affected.
  • Focus more on the quality of code. i.e. making sure that every method works with different inputs under varying circumstances.
  • Deploy with confidence.

The above are a few benefits of automated testing. for a detailed explanation, please read how automation adds value to your test by Roshika Guaranthne.

source: Developer Experience Knowledge Base.

Types of Automated Test

1) Unit Test: Is used to test a unit of an application without its external dependencies such as files, databases, message queues, etc. It is great for quickly testing the logic, conditional statements, and loops so as to verify that each block in the application is working as expected.
Although, unit tests are easier to write and they execute really fast (since no external dependency is involved) but they do not give a lot of confidence in the reliability of the application since the blocks/classes of codes are not tested with their dependencies.

2) Integrated Test: Is used to test the application with its external dependencies (files, databases, etc.). Unlike unit tests, integrated tests take longer to execute because it often involves reading and or writing to a data database.
It also gives more confidence in the reliability of the application and provides many advantages of end-to-end (e2e) test but without the complexity of dealing with the user interface.

3) End-to-End Test (e2e): Drives an application through its user interface (UI). Compared to integrated tests, e2e gives the greatest amount of confidence although it is the slowest because it requires launching the application and testing it through its UI. Every test is going to launch the application, perform authentication, navigate to an internal page or submit a form and expect a result.
It is also important to note that e2e is inflexible because a small change in the application or UI can easily break a test.
Therefore, it is advisable to:
- sparsely use e2e.
- only for key functions of the application.
- only test the happy paths (passing tests).
- leave the edge cases (failing tests) to unit and integration tests.

Automated Testing Tools

To write an automated test, there is a need for a testing tool. Automated testing tools run and execute the scripts that examine the application, report and compare the test results. Automated tools also known as testing frameworks provide a library that includes various utility functions and a test runner — a program run from the command line that executes the test and returns a report number of failed or passed tests.
Some of the top essential javaScript testing tools include; webDriver, TestCafe, Cypress, Protractor, and NightwatchJS which are good for e2e tests also, Jasmine, Mocha, and Jest which are great for both unit and integrated testing.

I hope you find this article helpful. For the next step, visit my next article on how to setup your typeScript app test environment with jest.

👋

Resources

If this post was helpful, please click the clap 👏 button below a few times to show your support for the author 👇

🚀Developers: Learn and grow by keeping up with what matters, JOIN FAUN.

--

--