Lab 8 Blog

     Lab 8 was about managing a project complexity through automated testing, this week we worked on our Release 0.1 link checker by creating testers using Jest and other testing frameworks for the language we used in our project. Adding automated testing sequences for projects is important for consistency, usability, and security for any application. A good and solid testing program covers most of the code with different testing methods.

    Different languages require a different testing framework to set up with, and since my project was written in Node.js, the best choices I had were either Jest (created by Facebook) or Mocha. I went with Jest because I am familiar with React which was made by the same company so I could expect handling similar coding styles. Jest can be installed by using the Node Package Manager and then activate the command by declaring the test scripts in package.json.


 To get started with testing, write your first test by creating a test.js file that imports the functions from existing code files and write your first tests using the test() function.

At first, I was stumped on what I could test because most of my functions do not actually return anything due to them only prints out results to the console. I then settled on testing the function that converts all command-line arguments into boolean or strings within an object of their validness. Figuring out what to test made me realize the faults in my code, the way I implemented my code isn't tester friendly which is a fatal error for there is nothing that can be physically tested through returned values. In the future, I will make sure any types of functions, even the ones that only output to the console will instead return a string or throw errors to allow for a better testing experience.

During the implementation of the network mock tests, I was able to improve my code by separating the process of making URL requests to its individual function to increase re-usability and allow for testing.

In this lab, I learned that it is very important to make sure every procedure of the project returns some sort of value, as well as throwing an exception when an unfavored situation is reached. For all my future projects I will design my program to be easily tested on.

Comments

Popular posts from this blog

Lab 2 Blog

Lab 4 Blog

Release 0.4