Software Testing Methods

Tram Ho

Software testing is essential to ensure that your application will function correctly in conjunction with the development of application functionality. To do that, you can apply basic testing methods: unit test (test levels), white box test, black box test.

The first will be White box testing

White box testing

White box test is a test of software structure, design and code. Focus on input and output to improve design, usability, and enhance security based on the internal workings of the application as well as internal testing. And the name says it all, it symbolizes that we can see the activity within it.

To perform the white box test, we need to follow the basic steps

  • Understand the source code: This is the first thing to do, because white box testing involves testing the inner workings, it is imperative to understand the source code that we need to test. In addition, we need to implement strict security encryption because security is at the core of this test.
  • Create and execute test cases: Writing more code snippets to test the application source code will be the next thing to do. Small tests need to be developed for each process or for each process sequence in the application (more information can be found here ).

A simple example with the following code

The goal is to identify all branches, loops, and statements in the code above.

And the test cases of white box testing will be

The above test cases will cover the conditions, branches as well as the commands in the code.

Types of white box testing

  • Unit testing: this is the first test method performed to test an application. This method is quite important so we will discuss it right after reading the Black box testing method.
  • Testing for Memory Leaks: Memory leaks are a leading cause of slower application execution. And when there is such a phenomenon, it is necessary to think of this case immediately.

There are also some other methods, such as White Box Penetration Testing and White Box Mutation Testing

White box testing also has certain advantages:

  • Optimize source code by finding hidden bugs.
  • Easy to do automatically, but also more thorough
  • And the test may start soon even if the GUI is not available.

Its disadvantages:

  • Implementation is quite complex and costly.
  • Requires testers to be really professional and knowledgeable about programming.
  • Spend a lot of time

Black box testing

Black box testing is a software testing technique that tests the functionality of an application based on the specifications without looking at how the internal code structure looks. It is based entirely on software requirements and specifications. The black box test only focuses on the input and output when performing the test, regardless of how the code inside is built.

To conduct black box testing, follow these steps:

  • Choose a valid input (positive test scenario) to check if the processing is correct. Simultaneously, scripts with invalid input are also executed to detect errors.
  • Testers need to determine expected all inputs.
  • Perform tests with the inputs prepared for each case
  • The test case is done.
  • Compare the received output with the expected output.
  • Identify points of error and perform a retest.

Perform two methods of White box testing and Black box testing

Black Box TestingWhite Box Testing
The focus is on confirming the functional requirementsConfirm the internal structure and operation of each piece of code
Focus on the results of the software system and can skip the source code reviewUnderstanding the source code is extremely necessary
Facilitate the communication between modulesDo not facilitate checking communication between modules

Unit test

Unit testing is a type of software testing where its components will be tested individually, components that can be methods, classes, modules … to isolate each piece of code separately to test. its accuracy. And it is done by programmers. Sometimes, they will skip unit tests and only do Integration test . However, not all errors can be detected if integrated testing is performed, and finding and fixing bugs is extremely complicated and time-consuming. So it can be said, do not ignore unit tests because you think that it will take too much time to write it.

Some advantages of unit tests that make it impossible to say no to:

  • Examining each piece of code in the development stage helps early find out bugs and fixes —> cost savings.
  • Programmers understand each piece of code and can quickly modify it if required.
  • Create project references.
  • Reusing the code while ensuring its accuracy —> saves both time and money.
  • Because it is testing each unit, it is possible to execute components of the project in parallel without being bound or dependent on others.

Unit tests come in two types: manual and automated, and usually automated is used more commonly, although it can still be performed manually.

The unit test only tests each piece of code with each individual function so that it cannot detect integration errors or system errors when multiple pieces of code are executed at the same time. Its advantages also become its greatest disadvantages.

To perform unit tests, we should prepare:

  • Units to be tested must be truly independent.
  • Test only one piece of code at a time.
  • The naming of each test piece must be consistent and clear.
  • If a module changes, it is necessary to have corresponding test cases before applying it.

References

https://www.guru99.com/unit-testing-guide.html

https://www.guru99.com/white-box-testing.html

https://www.guru99.com/black-box-testing.html

Chia sẻ bài viết ngay

Nguồn bài viết : Viblo