Testing Introduction - AutolabJS/autolabcli GitHub Wiki

What is Software Testing?

Software testing is a procedure to investigate the quality of a software product in different scenarios. It can also be stated as the process of verifying and validating that a software program or application works as expected and meets the business and technical requirements that guided design and development.

Why Software Testing?

Software testing is required to point out the defects and errors that were made during different development phases. Software testing also ensures that the product under test works as expected in all different cases – stronger the test suite, stronger is our confidence in the product that we have built. One important benefit of software testing is that it facilitates the developers to make incremental changes to source code and make sure that the current changes are not breaking the functionality of the previously existing code.

Testing in NodeJS.

Testing in NodeJS is can become tricky because of its asynchronous nature. But, We have testing frameworks like Mocha and Jasmine which has made testing nodejs applications increasing easy. Mocha is the most widely used testing framework which is used along with Chai, an assertion library. We use Cucumber framework for BDD tests to test a feature of the application. Before we dive into each one of these testing frameworks, let us understand what TDD and BDD mean.

What is TDD?

TDD stands for “Test Driven Development”. It is a software development process that relies on the repetition of a very short development cycle: first the developer writes an (initially failing) automated test case that defines a desired improvement or new function, then produces the minimum amount of code to pass that test, and finally refactors the new code to acceptable standards. The goal of TDD can be viewed as specification and not validation. In other words, it’s one way to think through your requirements or design before your write your functional code.

tdd-flow

What is BDD?

BDD stands for “Behaviour Driven Development”. It is a software development process that emerged from TDD. It includes the practice of writing tests first, but focuses on tests which describe behavior, rather than tests which test a unit of implementation. This provides software development and management teams with shared tools and a shared process to collaborate on software development. BDD is largely facilitated through the use of a simple domain-specific language (DSL) using natural language constructs (e.g., English-like sentences) that can express the behavior and the expected outcomes. Mocha and Cucumber are built around the concepts of BDD.

References