DEV Community

Cover image for Testing. Testing. 123..
Ronald R
Ronald R

Posted on

Testing. Testing. 123..

For this lab I wanted to make a heavier techincal blog than just my regular blog just so I can get a feel how this blogging works.
3a68733 this was the commit I did for this week. I updated the contribution.MD file to show how to properly work on Waypoint. In this Lab we worked on tesing.

  • 1st and Main commit

Added a testing framework for initial unit tests creation - during this commit I needed to somehow figure out a framework to use with my project. Since I was working with python I had a couple of options, I decided to ues nose2 and unittest for this.

Breaking down this code I needed to set up the framework where I would be able to use unnittest and also import the functions I needed to create the testing module.

import unittest
from waypoint import process_text, process_file, set_config
from testing import argtest
Enter fullscreen mode Exit fullscreen mode

I had a total of 9 testing that I needed to ensure that all the function works. In those 9 I tested all the main core of the project which is convertion

  1. String to Html
  2. txt File to Html
  3. Md file to Html
  4. toml file processing
  5. folder processing and conversion

the next test i needed was to ensure the system arguments condition are met properly

  1. -h for help
  2. -v for version
  3. -c for config file
  4. test to fail.

I added a test to fail to ensure that the program and testing are working properly. This was mostly for my personal agenda, just because testing is an area I am very unfamilliar that I needed to ensure that all if not most testing are done properly.

Now the testing depndicies i used was nose2 and unittest

python -m unittest discover -k "test_txt" # To test a string
python -m unittest discover -k "test_txtfile" # To test a txt file
python -m unittest discover -k "test_tomlfile" # To test a toml file
python -m unittest discover -k "test_folder" # To test a folder file
Enter fullscreen mode Exit fullscreen mode

these codes where use to test the unit individually as oppose to all. I installed nose2 to actually run everything, yes I know unittest has the capability of it being able to run but i found it easier to use nose2 when running the test plus it provided me an option to add a watcher which sadly unittest did not.

Now for coverage It was simple enough to use, which was coverage.py to run it all. I realized I now have multiple way to test my program!

This was a very challenging lab as testing was something I really wanted to get my hands on but did not know where to start, looking back at my work during Hacktoberfest it took me days to actually figure out how to test the thing I did, which this came in sooner but oh well, at least now I know. On to the next one!!

Top comments (0)