Software Testing

Software Testing

Some say it takes much to come up with a good software product while others say it’s just a walk over; all in all, these opinions vary from one software developer to another, the time available and the goal for which the software is being built.

Putting these factors a side, there are fundamentals or good practices of software development and among these is; software testing.

What exactly is software testing?

As the name suggests, software testing is an investigation carried out to provide stakeholders with information about the quality of the software product or service under test. In simple words, it is a verification conducted on the software product during its production to confirm that it meets the goals for which it is made. Over the past few years,software testing has improved as development teams have created strong protocols and built automation features to help in testing. Software testing is so broad a topic thus we shall focus on unit testing.

Unit Testing

Unit testing is the first level of software testing and is an approach where individual units of source code, sets of one or more computer program modules together with associated control data, usage procedures, and operating procedures, are individually and independently scrutinized to determine whether they are fit for use and this can be done both manually or automatically.

A unit can be viewed as the smallest testable part of an application and could be an entire module or just a function or method.

Unit testing is a component of test-driven development (TDD), an approach used to create a product by means of continual testing and revision. In Test-driven development, developers first write failing unit tests after which they write code and refactor the application until the test passes.

It involves only those characteristics that are vital to the performance of the unit under test. This encourages developers to modify the source code without immediate concerns about how such changes might affect the functioning of other units or the program as a whole. Once all of the units in a program have been found to be working in the most efficient and error-free manner possible, the units are then put together to form larger components of the program.

Some of the advantages of unit testing include;

  • Increased confidence in code changing/ maintenance.
    When good unit tests are written and run every time any change is made in the code, defects  introduced due to the change are easily and promptly caught. Also, if the code is already less interdependent (units not interconnected) to make unit testing possible, the unintended impact of changes to any code is less.
  • Reusable code
    In order to make unit testing possible, the code needs to be modular (in units) thus easier to reuse.
  • Faster software development
    Without unit testing, more time is wasted creating the code and probably a GUI just to test the code but with unit tests, there could be just simply writing and running the unit code
  • The cost of fixing a bug detected during unit testing is lesser in comparison to that of bugs detected at higher levels in the product development.
  • Debugging is easy
    When a test fails, only the latest changes need to be debugged. With testing at higher levels, changes made over the span of several days/weeks/months need to be scanned.
  • The code is more reliable since all the units that are used are well tested and fully function as required