Getting started with testing (PHP and javascript) - PART 1

Testing has its place in the development phase, often related as unit testing since the programmer write test cases for the smallest part of the code, such as a method of a class or a function. Therefore, to reach a level of confidence and write tests as a routine during the development cycle is a challenge for many programmers.

The aim here is to give a guide line to get started with unit testing, and to reach a level of confidence to improve the development cycle, thus the programmer productivity.

Prerequisites

The first step to star get into the unit testing, is to chose a programming language that you are comfortable with.

The foundation is the same, as mentioned in the introduction, though, tools for each programming language vary, meaning, each programming language has its own tools and conventions to write unit tests (even tough the theory that underlies it is the same).

Make sure to have at least one year of experience in any programming language, and at least developed an application of any kind. This may setup the ground to ease the path of unit testing.

Programming languages, tools and frameworks

Tools for testing vary based on the programming language and on the framework as well. For PHP for example, one of the most used libraries to write unit tests is PHPUnit. For java is Junit and for javascript the libraries are categorized in two: front end and backend.

Javascript has more granularity compared to JUnit and PHPUnit, the ecosystem provides libraries for assertion and libraries for running the tests, as opposed to PHPUnit and JUnit that has this feature built-in. Though, it is possible to also find the same behavior in the javascript ecosystem as well.

Foundation on testing

As a beginner on the the testing subject, there are more questions than answers. Which is fine and a good starting point. This section provides references for understanding the foundation of testing, but not just the theory, the practice as well.

The first recommended read of this section, if you are the developer that prefers to see the code before reading the theory is: TDD by example [1].

On the other hand if you prefer to digest more theory and then later on go deeper into the practical aspect of it, then the suggested reading is: Software Engineering Tenth edition by Ian Sommerville [2].

Whichever you picked first, once it is done, go to the next one before proceeding to the next set of references.

For a deep dive into the software testing, the recommended reading is The Art of Software Testing [3].

References

  1. [1]K. Beck, TDD by example. Addison-Wesley Professional, 2000.
  2. [2]I. Sommerville, Software Engineering Tenth edition. Pearson Education Limited, 2015 [Online]. Available at: https://www.amazon.es/Software-Engineering-Global-Ian-Sommerville/dp/1292096136. [Accessed: 15-Jul-2015]
  3. [3]G. Myers, The Art of Software Testing. Wiley, 1979.
Share this on