Chapter 13. Test Drive your Visualization

In this chapter we will cover:

  • Getting Jasmine and setting up the test environment
  • Test driving your visualization – chart creation
  • Test driving your visualization – SVG rendering
  • Test driving your visualization – pixel-perfect bar rendering

Introduction

Whenever we program as a professional programmer it is always important to test the program we write in order to make sure it functions as designed and produces the expected outcome. D3 data visualization mainly consists of JavaScript programs hence just like any other program we write, data visualization needs to be tested to make sure it represents the underlying data accurately. Obviously, we can perform our validation through visual examination and manual testing, which is always a critical part of the process of building data visualization since visual observation gives us a chance to verify not only the correctness, but also the aesthetics, usability, and many other useful aspects. However, manual visual inspection can be quite subjective, therefore, in this chapter we will focus our effort on automated unit testing. Visualization well covered by unit tests can free the creator from the manual labor of verifying correctness by hand additionally, allowing him/her to focus more on the aesthetics, usability, and other important aspects where it is hard to automate with machine.

Introduction to unit testing

Unit testing is a method in which a smallest unit of the program is tested and verified by another program called the test case. The logic behind unit testing is that at unit level the program is typically simpler and more testable. If we can verify if every unit in the program is correct then putting these correct units together will give us a higher confidence that the integrated program is also correct. Furthermore, since unit tests are typically cheap and fast to execute, a group of unit test cases can be quickly and frequently executed to provide feedback whether our program is performing correctly or not.

Software testing is a complex topic and so far we have only scratched the surface; however, due to limited scope in this chapter, we will have to stop our introduction now and dive into developing unit tests.

Note

For more information on testing please check out the following links:

Test driven development: http://en.wikipedia.org/wiki/Test-driven_development

Code coverage: http://en.wikipedia.org/wiki/Code_coverage

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset