0.3 release Unit testing

For our 0.3 release of implementing WebVTT parser, we had to do a bunch of things like finishing the cue text parsing part, implementing tests automation, writing unit tests etc. I was sort of interested in writing unit tests. So to begin with I pulled all the changes from humphd’s seneca branch and then build the parser using ./configure and make commands. It built successfully. Although I had a bit of trouble building it because I was not building it from root directory. So it was giving me all sorts of errors when I was trying to build from other directories and not from root. But I figured that out soon enough. Then I went ahead and installed the modules for node-ffi, ref, and ref-struct since we are using node-ffi for data bindings. It was a one command process. The command is “sudo npm install ffi ref ref-struct”.
To make myself a bit familiar with generating dynamic libraries and all, I used the factorial example provided by node-ffi team. The command I ran to test the factorial example was “gcc -dynamiclib -undefined suppress -flat_namespace factorial.c -o libfactorial.dylib”. And it worked with no errors. And then I was on IRC and dperit mentioned that he had a sample program to test the node ffi bindings done by caitp . I pulled his github repo and merged it with mine. But it had some errors probably because the export function in the unit-test.js file expects four variables and we were only passing three in sample.js. Anyways, so I was trying to study the code in unit-test.js and in sample.js because I had no previous experience working with javascript. And then I came across this another javascript framework named o2. The owner of this project also has blog posts about how to write unit tests in javascript and he goes on to explain how u can manage a queue of unit tests. Basically, what he has for his o2 project is a o2.unit.core.js file and the file manages a queue of tests, manages total number of failed and passed tests, the time interval between tests, completion status, etc. The test files from elsewhere can call the methods in this library to perform testing. I am looking to implement the same kind of approach for our project too. So, I have took their file and i am trying to modify it to suite our needs. For this, I have studied a lot of code. I suppose, it should also make the test automation easier for us.

Advertisements

One thought on “0.3 release Unit testing

  1. Volkan Ozcelik

    I’m glad that the blog post was useful.

    I will continue to write on similar posts after I finish my book 😉 — never thought how hard it’d be to write a book in the first place.

    Cheers,
    Volkan.

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s