Introducing
The Slant team built an AI & it’s awesome
Find the best product instantly
Add to Chrome
Add to Edge
Add to Firefox
Add to Opera
Add to Brave
Add to Safari
Try it now
4.7 star rating
0
Development
What are the best Python unit testing frameworks?
5
Options
Considered
115
User
Recs.
Aug 6, 2023
Last
Updated
Related Questions
Activity
Have feedback or ideas?
Join our community
on Discord
Ad
5
Options
Considered
Best Python unit testing frameworks
Price
Last Updated
74
pytest
0
Jul 31, 2023
52
nose
-
Jan 26, 2022
--
vedro
0
Aug 6, 2023
--
ward
-
Aug 24, 2022
--
unittest
FREE
Jul 18, 2020
See Full List
74
pytest
My Rec
ommendation
for
pytest
My Recommendation for
pytest
All
11
Experiences
1
Pros
9
Cons
1
Top
Pro
•••
Allows for compact test suites
The idioms that pytest first introduced brought a change in the Python community because they made it possible for test suites to be written in a very compact style, or at least far more compact than was ever possible before. Pytest basically introduced the concept that Python tests should be plain Python functions instead of forcing developers to include their tests inside large test classes.
See More
Top
Con
•••
Compatibility issues with other testing frameworks
The fact that pytest uses it's own special routines to write tests means that you are trading convenience for compatibility. In other words, writing tests for pytest means that you are tying yourself to only pytest and the only way to use another testing framework is to rewrite most of the code.
See More
loulou's Experience
I'm not really experienced with it ; I tried it out this morning. But it is just really simple to get started with, a lot of things are working as they should be supposed to, and what is always important, the documentation is clear and abundant !
See More
Top
Pro
•••
Minimal boilerplate
Tests written with pytest need very little boilerplate code, which makes them easy to write and understand.
See More
Top
Pro
•••
Extensible (many of plugins are available)
Pytest can easily be extended with several hooks, and the same team develops a number of very useful plugins. For example, you install pytest-xdist, and parallel test execution just works, with all the same benefits you had with pytest (as opposed to having to use a separate test runner, for example)
See More
Top
Pro
•••
Fixtures are simple and easy to use
A fixture is just a function that returns a value and to use a fixture you just have to add an argument to your test function. You can also use a fixture from another fixture in the same manner, so it's easy to make them modular. You can also parametrize fixture and every test that uses it will run with all values of parameters, no test rewrite needed. If your test uses several fixtures, all parameters' combinations will be covered.
See More
Top
Pro
•••
Very pretty and useful failure information
With most other tools you have to use debugger or extra logging to find out where did some value came from in your test. Not with pytest! Pytest rewrites your test so that it can store all intermediate values that can lead to failing assert and provides you with very pretty explanation about what has been asserted and what have failed.
See More
Top
Pro
•••
Tests parametrization
You can parametrize any test and cover all uses of a unit without code duplication.
See More
Top
Pro
•••
Pdb just works
Pytest automagically (and safely) disables output capturing when you're entering pdb, so you don't have to redirect debugger to other console or bear huge amount of unneeded output from other tests.
See More
Top
Pro
•••
Provides special routines to make testing easier
Pytest provides developers with special routines to make test writing easier. This makes writing tests less error-prone and all around simple. It also results in shorter and more readable code.
See More
Top
Pro
•••
Test discovery by file-path
See More
Hide
See All
0
Recommend
68
7
52
nose
My Rec
ommendation
for
nose
My Recommendation for
nose
All
5
Pros
3
Cons
2
Top
Con
•••
May be losing support or cease altogether
According to documentation at https://nose.readthedocs.io/en/latest/, nose may become unsupported. There is a successor project called Nose2 (https://github.com/nose-devs/nose2), but it does not support all the features of its predecessor and recommends considering pytest for those new to testing.
See More
Top
Pro
•••
Supercedes unittest
Nose wraps around unittest, adding some more feature and functionality to it, such as SkipTest or auto-discovery.
See More
Top
Con
•••
Too much reliance on plugins
Having lots of plugins while beneficial, also can be a hindrance. Relying too much on them makes developers feel as if everything's being done by plugins which a lot of times are undocumented or have very little documentation.
See More
Top
Pro
•••
Minimal boilerplate
Nose tries to keep boilerplate code to a minimum. As such, it's very easy to read and write initial tests.
See More
Top
Pro
•••
Numerous plugins available
There's a large number of plugins available for nose which make unit testing easier. Things like coverage reporting, test selection and xUnit-compatible test output can be added through plugins.
See More
Hide
See All
Get it
here
Recommend
17
3
--
vedro
My Rec
ommendation
for
vedro
My Recommendation for
vedro
Hide
0
Recommend
1
--
ward
My Rec
ommendation
for
ward
My Recommendation for
ward
All
4
Pros
3
Cons
1
Top
Pro
•••
Async fixtures
Fixtures can await asynchronous code.
See More
Top
Con
•••
Not many plugins available (in 2022)
While ward has a plugin system, there are not many plugins available as of 2022. Alternatives, like pytest, have many more plugins to choose from.
See More
Top
Pro
•••
Explicit fixtures
Test fixtures are referenced explicitly, which helps both humans and IDE's understand which fixture is used.
See More
Top
Pro
•••
Encourages better test names
Tests are named by markdown strings, not the function name of the test.
See More
Hide
See All
Get it
here
Recommend
1
--
unittest
My Rec
ommendation
for
unittest
My Recommendation for
unittest
All
11
Experiences
1
Pros
6
Cons
4
Top
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.
See More
Top
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.
See More
IntellectualAkras's Experience
Full freedom. Nothing superfluous and unnecessary. Simple and transparent. No problems with intermediaries and compatibility.
See More
Top
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 TextTestRunnerwhich 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.
See More
Top
Con
•••
No color output
See More
Top
Pro
•••
Promotes grouping related tests into common test suites
See More
Top
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.
See More
Top
Pro
•••
Very fast test collection
See More
Top
Con
•••
Verbose
Too much boilerplate code is needed.
See More
Top
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.
See More
Top
Pro
•••
Very precise test duration reports
Unittest reports tests duration in milliseconds
See More
Hide
See All
FREE
Recommend
8
10
Don't see your favorite option? Add it.
Built By the Slant team
Find the best product instantly.
4.7 star rating
Add to Chrome
Add to Edge
Add to Firefox
Add to Opera
Add to Brave
Add to Safari
Try it now - it's free
One sec!
Are you sure that you want to abandon your hard work?
Delete Work
Continue working
{}
undefined
url next
price drop