testing Archives - SoftUni Global https://softuni.org/tag/testing/ Learn Programming and Start a Developer Job Wed, 30 Mar 2022 11:50:58 +0000 en-US hourly 1 https://wordpress.org/?v=6.1.3 https://softuni.org/wp-content/uploads/2022/04/cropped-SoftUni-Global-Logo-Square-notext-32x32.png testing Archives - SoftUni Global https://softuni.org/tag/testing/ 32 32 What You Need to Know About Unit Testing [Dev Concepts #27] https://softuni.org/dev-concepts/what-you-need-to-know-about-unit-testing/ https://softuni.org/dev-concepts/what-you-need-to-know-about-unit-testing/#respond Thu, 27 Jan 2022 07:10:00 +0000 https://softuni.org/?p=11046 In this article of the series Dev Concepts, we take a look at Unit Testing and Testing Frameworks.

The post What You Need to Know About Unit Testing [Dev Concepts #27] appeared first on SoftUni Global.

]]>

Unit testing is an important concept and practice in software development. As a term, unit tests are pieces of code that test specific functionality in a certain software component. Usually, they are not written by QA engineers but from the developers that wrote the code. Unit tests are part of the product source code and aim to improve the code quality, reliability, and maintainability.

unit_testing_guidelines

Unit testing frameworks simplify, structure, and organize the unit testing process. It executes the test and generates reports. The developers organize tests in a hierarchy using classes and functions. After that is done, they assert the execution result and exit all conditions for correctness. Examples of unit testing frameworks are: JUnit for Java and Mocha for JavaScript.

boxes-unit-testingThe Unit testing techniques are mainly categorized into three parts which are Black box testing that involves testing of user interface along with input and output, White box testing that involves testing the functional behaviour of the software application and Gray box testing that is used to execute test suites, test methods, test cases and performing risk analysis.

Unit test developers usually follow the “AAA pattern“. It stands for:

  • arrange the input data and entrance conditions
  • act – execute the function for testing
  • assert whether the results and the exit conditions are as expected

In the arrange section, you have the code required for setting up the specific test. Here is where we create objects and potentially set expectations. Then there is the act, which should be the invocation of the method being tested. In the assert, you would check whether the expectations are met.

unit-test-ticket

By implementing unit testing, it’s easier to catch and fix issues early before they cost extra time and money. It can become an important part of the overall software development process, helping to foster development more efficiently and productively. We should aim to write unit tests that focus solely on a single unit of code. With having more test reports, it will be easy to find the error in our code.

Lesson Topics

In this tutorial we cover the following topics:
  • Unit Testing
  • Unit Testing Framework

Lesson Slides

The post What You Need to Know About Unit Testing [Dev Concepts #27] appeared first on SoftUni Global.

]]>
https://softuni.org/dev-concepts/what-you-need-to-know-about-unit-testing/feed/ 0