cft

What is Software Testing ?

In this article, the general concept of software testing is explained.


user

Nadir Basalamah

2 years ago | 4 min read

In software development, there is an activity to make sure that software can be used effectively and is matched with the software’s specified requirements. The activity is called software testing. Software testing is used to ensure a software can be used effectively without any bug or defect.

What is Software Testing ?

Software testing is an activity to ensure a software can be used effectively and matches with the software’s specified requirements. Software testing is usually done by Quality Assurance or by developer.

Software Testing Types

There are two main types of software testing including black box and white. Based on the testing level, there are four types of testing including unit testing, integration testing, system testing and acceptance testing.

White Box Testing

White box testing is a testing activity that focuses on many components that are involved in a software including code, algorithm and other related components. White box testing can be done manually using Control Flow Graph (CFG) and also automatically with code. White box testing activity including unit testing and integration testing.

Unit Testing

Unit testing is a testing activity that focuses on the smallest unit in a software like a function or algorithm. The purpose of unit testing is to ensure the unit is implemented correctly. Unit testing can be done by using Control Flow Graph (CFG) to define the flow of a certain function then the value called cyclomatic complexity is calculated from Control Flow Graph. The result from cyclomatic complexity is used to define the number of test cases for testing.

This is the list of notations that can be used to create a Control Flow Graph. 

Control Flow Graph Notations

This is the formula for cyclomatic complexity calculations:

  • V(G) = Numbers of Predicate Node + 1
  • V(G) = Numbers of Edge - Numbers of Node + 2
  • V(G) = Numbers of  Region

Predicate node is a node that has a branch whilst region is a region in a function and also a region that has a branch.

This is an example of unit testing for the insertData() function. This function is implemented in Go.

package simpledb


import "fmt"


var db []string = []string{}


func insertData(data string) bool {

// perform validation

if data == "" {

fmt.Println("Data not valid!")

return false

}


db = append(db, data)

fmt.Println("Data inserted!")

return true

}

This is the Control Flow Graph with cyclomatic complexity calculation for insertData() function.

Create a Control Flow Graph

Calculate the Cyclomatic Complexity

Based on the cyclomatic complexity calculation result, there are two test cases that can be used to test the insertData() function. This function is tested using Go.

package simpledb


import "testing"


// test case 1: with valid data

func TestInsertData(t *testing.T) {

var data string = "burger"

var expected bool = true

var result bool = insertData(data)


if result != expected {

t.Error("Expected: ", expected, " Got: ", result)

}

}


// test case 2: with empty data / invalid data

func TestInsertDataEmpty(t *testing.T) {

var data string = ""

var expected bool = false

var result bool = insertData(data)


if result != expected {

t.Error("Expected: ", expected, " Got: ", result)

}

}

Test result.

Data inserted!

Data not valid!

PASS

ok      github.com/nadirbasalamah/golang-basics/simpledb        3.709s

Integration Testing

Integration testing is a testing activity by integrating related units in a software. Integration testing is used to ensure an unit can be used properly in a component that is used the related unit.

This is an example of integration testing in the insert() function. The insert() function is use another unit which is the insertData() function.

Implementation of insert() function.

func insert(data string) bool {

// using insertData() function

var result bool = insertData(data)

if result == false {

return result

}

return result

}

Integration testing in insert() function.

func TestInsert(t *testing.T) {

var data string = "ice cream"

var expected bool = true

var result bool = insert(data)


if result != expected {

t.Error("Expected: ", expected, " Got: ", result)

}

}

Test result.

Data inserted!

Data not valid!

Data inserted!

PASS

ok      github.com/nadirbasalamah/golang-basics/simpledb        0.970s

Another Example of White Box Testing

If a software is developed using certain architecture like Model View Controller (MVC) then the process of the testing looked like this:

  • Unit testing is performed in a model because the model is the smallest unit.
  • Integration testing is performed in a controller because the controller uses a function from the model so the integration between controller and model is tested.

Black Box Testing

Black box testing is testing activity that focuses on a software usage without knowing the component in a software. Black box testing is performed by using software based on the functionality that will be tested. For example to test the login functionality, the login functionality is used to ensure the login functionality can be used effectively. Black box testing including system testing and acceptance testing. Black box testing is used to test the main requirement (functional requirement) and non functional requirement.

System Testing

System testing is a testing activity that can be done by using the system or software based on the functionality that will be tested. For example, to test the functionality to add new data. The process to add new data is executed to ensure the functionality can be used effectively.  Another example of system testing is instrumentation testing for Android Mobile Application.

Acceptance Testing

Acceptance testing is a testing that is performed by a client or stakeholder that will use the software. Acceptance testing is used to ensure the software can be used effectively and matches with the requirements and expectations.

Alpha and Beta Testing

Other types of software testing are called alpha testing and beta testing.

Alpha testing is a testing activity that can be done in a controlled environment  which is a developer environment and the tester is a person from the developer or quality assurance team. This testing is performed by using software regularly. When the bug, error or defect is found then the software can be fixed directly.

Beta testing is a testing activity that can be done in an uncontrolled environment like a user environment. The tester is a regular user of the software. The test is performed by using software regularly. Users can give feedback to the developer team if there is something wrong or something that can be improved from a software.

Sources


I hope this article is helpful to learn about software testing. If you have any thoughts you can write it in the comments section below.

Upvote


user
Created by

Nadir Basalamah

A guy who interested in web development and software engineering


people
Post

Upvote

Downvote

Comment

Bookmark

Share


Related Articles