Gabriel
Gabriel

Reputation: 42329

Adding unit testing to a large python project

I started learning python as I developed a project about a year ago. Since then the project became somewhat of a (quite large) stable and useful tool for me. The project's arrangement is like so:

main.py
../functions/func1.py
../functions/func2.py
../functions/func3.py
../functions/func4.py
...
../functions/funcN.py

where the main.py file calls the rest of the functions sequentially.

The issue is that I did not write a single unit test for any of the functions. Not one. I did not pay much attention to testing since at first I was just learning and eventually it got out of hand.

I want to correct this and add the proper unit tests, the question is: which testing method should I use for my project?

I've seen many different methods described:

but I've no idea if one of those is more suited to something like my project than the rest.

Upvotes: 2

Views: 1439

Answers (1)

simonzack
simonzack

Reputation: 20928

unittest which is now just unittest2 is already in python and the most standard, just start with that.

Think of nose as a set of extensions, use it when you want something not already in unittests, it's quite popular as well.

doctests puts unit tests into doc comments, I don't like it too much but use it if you want to.

mock is just a testing paradigm you should use when interacting with interfaces/objects is not trivial

tox runs tests under different python environments.

As an addition, integration tools like travis/jenkins allows you to run tox or sets of unit tests automatically, they're often used for multi-user projects, so everybody can see the test results on each commit.

Upvotes: 3

Related Questions