Monday, November 30, 2020

Lab 8+9 = Double Trouble

 Hey PC readers,

Welcome back to my blog!

So this week was double trouble, as we got two labs combined in one. In all fairness, we did get two weeks too. 😅😅

As usual, busy with work and college, but I started reading and researching about it in first week, but did not do much of the work in the first week. The first task was to setup a testing framework. I used Jest as I already heard a bit about it in my past experience but never worked with it. I started installing it using 

npm install --save-dev jest

It was pretty straight forward, I could run it easily by just typing "jest" and the tests suites would run. Now, for that to happen, we just needed teeny meeny test cases which are not so teeny meeny actually. You need to get a hold of it, then they are not that difficult. But understanding them at first, takes some time. I did write few before on Telescope also, but that didnt make it very easy for me. I needed a refresher again. 😕

Second step, was to add my first test case, I created test cases to check various commands taken from the users. For example: if a user was checking the version of the url-inspector, it should be correct. So I wrote a test  case for that. I went on to add multiple other scenarios that I was working with in the code. So tried to write as many cases I could. Finally, I finished writing the cases with the asked Third step of checking the 200 and 404 status code. I added those test cases also. It was all working nicely.

 Next, I added the code coverage. We could easily run the coverage by adding --coverage to the the jest command. I also created a script to run the coverage: npm run coverage. I also added all the info in the Contributing.md also for the users to run it properly.

Next step, was to merge everything in the master branch. I rebased and merged everything to the master in a squashed commit. Now, all that was left to do was to add CI(Continuos Integration) to our repo which will initiate the checks everytime there is a pull request to the master branch or any push to the master branch. It is done to ensure there is no code breaking the master code by initiating the automated tests. I added the Github Actions Workflow and checked that by adding a PR to the master branch. My YAML looked like this:

 

Next, I added some test cases to one of my mate's repo. I included the test case to check the Manual is getting printed as it should. Her repo was very neatly modularized and tests were easily understandable. I tried to be as consistent as I could with her style of coding.When I ran my test, it was working, and details can be found here:

https://github.com/Shinh18/urltester/pull/10

 

I did do the testing before, but it was Black box testing, mostly manual or by pre-defined scripts. Learning to automate testing, is a good experience for me, since everything is going to be automated soon.

Thanks for reading my blog! See you next week.

Best,

PC

Lab 9 - The last chronicle

 Hey PC readers,  Welcome back to my channel! As the name says, this is our last lab of this semester Lab 9. In the last tale of the lighten...