When comparing HaLVM vs unittest, the Slant community recommends unittest for most people. In the question“What are the best unikernels?” unittest is ranked 4th while HaLVM is ranked 7th. The most important reason people chose unittest is:
PyUnit has been a part of the Python standard library since version 2.1 as the [unittest module](https://docs.python.org/2/library/unittest.html). This makes it widely available to developers without the need to install additional modules since it's coming out of the box with Python.
Ranked in these QuestionsQuestion Ranking
Pros
Pro Highly secure
What HaLVM does in simple terms is to provide only the minimal needed for an app to run. It provides only the required network and hardware drivers needed to execute.
Using this approach it minimizes the attack surface for potential hackers since they don't have any shell to log into or any other insecure cruft that other deployment methods, such as full operating systems have.
Pro Part of the Python standard library
PyUnit has been a part of the Python standard library since version 2.1 as the unittest module. This makes it widely available to developers without the need to install additional modules since it's coming out of the box with Python.
Pro Flexible test case execution
The way tests are run is through:
if name == 'main':
unittest.main()
Then unittest.main()
builds a TestSuite
object that contains all the tests that have method names starting with "test", then a TextTestRunner
which then executes each method and prints the results.
But individual test cases can be executed simply by specifying their names on the terminal:
python unittest_program.py testProgram.testGetFeedPostingHost
The default output is usually pretty concise, but it can be more verbose simply by adding a -v
flag in the end when calling the test from the command line.
So unittest can be considered pretty flexible when it comes to test case execution.
Pro Promotes grouping related tests into common test suites
Pro Very fast test collection
Pro Easy to use for people who are comfortable with testing in other languages
Since pyUnit is a derivative of xUnit and it's quite similar to other xUnit frameworks, it's quite easy for people with not much Python background to relate to.
Pro Very precise test duration reports
Unittest reports tests duration in milliseconds
Cons
Con Compiling from source can be problematic
Usually with cutting-edge software the compilation process never really goes as expected. Same is with HaLVM as well.
You may need to install additional libraries that are probably missing or even tweak configurations here and there. So it would be best to avoid this process if you don't feel comfortable enough with compiling from source. So you have to stick with the package manager of choice (if it's available for the particular Linux distro you are using).
Con camelCase naming
Idiomatic python code uses snake_case, but this was ported so closely from JUnit that it has retained java-style camelCase method names. That can be jarring.
Con No color output
Con The API can make the test code's intent hard to understand
Although unittest does not have a huge API that needs to be remembered, it has too much support for abstraction, this makes the test code intent's unclear.
Con Verbose
Too much boilerplate code is needed.