Overview of software testing in Angular JS (part 1)

Tram Ho

One of the factors that brings success to Angular JS is its ability to apply testing to the development of SPA (Single-page application) applications. Angular JS supports the implementation of various test areas, including Unit Testing, Partway Testing (Midway Testing) and End-to-End Testing. This article briefly introduces concepts related to testing in Angular JS.

1. Why test the application?

Before getting into the main content – applying software testing to applications built with Angular JS – I would like to briefly outline the concept and necessity of testing in the software development process, namely Software built on Angular JS platform.

For convenience of presentation, I will take a specific example of a manufacturing industry to illustrate the concepts that need to be explained here.

1.1 Example of testing in car manufacturing

Assume car company A establishes a car production line consisting of many parts and assembly plants located in many countries as follows:

In the illustration above, we can see that automobile parts can be manufactured at factories in different countries. These parts are made in accordance with the design specifications, so they can be assembled into a complete car. In reality, however, all activities have the potential to generate errors. What happens if the defect of some parts is only discovered after it has been shipped to the assembly plant or even after it has been delivered to the user? It is easy to see that these undetectable errors will consume a lot of time and cost for detecting, transporting, replacing and repairing, recalling products, compensating if damage occurs. Even its reputation is seriously affected.

Therefore, manufacturers all build a strict production process, in which testing is done as soon as possible and applied throughout the production and assembly process.

1.2 Testing in software development

Today, the software development process is also done in the way of breaking large software into small parts. Small parts of software are developed separately and assembled into a complete software product. Because it is built on a logical foundation, the software has a lot of potential deviations from what we envisioned when built. In addition, software is a non-visual structure, so these deviations are difficult to detect and accumulate over time.

According to calculations by NIST (National Institute of Standards and Technology), the cost of troubleshooting software errors over time will increase exponentially.

Early detection of defects in software is of utmost importance in ensuring progress as well as reducing development risks and costs. There are many approaches to software testing, the most common of which is classification of software testing by level, including:

  • Unit testing : Component testing is a testing method that focuses on testing the function of a program unit (unit) (usually a function, however in some models, such as Angular JS, the “unit” may be a Controller, a Directive, or a Service). Unit testing is done by the programmer who makes up the program function itself.
  • Integration Testing (Integration Testing) : a form of testing oriented to testing the correctness of communication through the interface between components of software. Integration testing is usually done by the QA (Quality Assurance) team.
  • System Testing : also known as End-to-End Testing, is a comprehensive testing of software that has been completely assembled to check whether the software requirements are met. fully meet or not? Testing the system by QA (Quality Assurance) team.
  • Acceptance Testing : Acceptance testing is performed at the actual place of deployment of the product, conducted by the orderer to ensure that the received product fully meets the requirements set out. . In software testing, acceptance test kits are often developed by the customer, or created by the customer in collaboration with the construction unit.

2. Types of tests in AngularJS

In the process of applying TDD (Test Driven Development) method to software development, projects always tend to automate the testing process (Automation Testing). Projects developed using Angular JS are no exception. As the Framework, Angular JS provides testing tools to help developers apply test methods as well as automate the testing process easily and quickly. Angular JS provides two main types of testing: Unit Testing and End-to-End Testing. Although there is another type, Midway Testing, which is a case of End-to-End Testing, in practice this type is rarely used.

2.1 Unit testing

Unit testing works on the principle of splitting and isolating the program units so that it can test the function of each program unit independently of the rest. To make it easier to imagine, we can see that in car manufacturing, each part of production is individually tested in a realistic simulation environment. The image below illustrates the wheel test:

2.2 End-to-End Testing

End-to-End testing tests the overall operation of the application by testing the functional performance from start to finish, from interface to communication with data source (access). web service or local storage area). It is conceivable that an End-to-End test is the process of performing an application’s function manipulated by a robot in a hidden browser according to a script we have programmed. In terms of applications developed with Angular JS, End-to-End Testing is System Testing. Contact with the example of testing in the car industry, End-to-End Testing corresponds to the quality control process of the product after assembly as shown in the image below. illustrated below:

References

https://angular.io/guide/testing

https://www.protractortest.org/#/

https://www.smashingmagazine.com/2014/10/introduction-to-unit-testing-in-angularjs/

Share the news now

Source : Viblo