Parametrized Unit Tests

Ben Finney ben+python at benfinney.id.au
Fri Aug 21 21:42:50 EDT 2015


rambius <rambiusparkisanius at gmail.com> writes:

> I am running one and the same unit tests that test some web
> application. I would like to execute them against different servers
> that may host different instances of the application.

Those aren't unit tests, then. A unit test, by definition, tests a small
unit of code; usually one true-or-false assertion about one function
call.

What you describe sounds more like integration tests or feature tests or
acceptance tests; something where large parts of the code base are all
exercised at once.

> Is there a better a way to pass the server, the user and the password
> to the test without resolving to global variables?

The ‘testscenarios’ library is one way to have a set of scenarios
applied at run-time to produce tests across all combinations
<URL:https://pypi.python.org/pypi/testscenarios/>.

> Although I developed these tests as unit tests they are more of
> integration tests. Is there an integration testing framework that
> supports a more convenient passing of test parameters / data?

You may want to look at behaviour-driven testing, e.g. using Behave
<URL:https://pypi.python.org/pypi/behave/>.

Another resource to use is the ‘testing-in-python’ forum
<URL:http://lists.idyll.org/listinfo/testing-in-python> where there is
more focussed discussion on testing in Python.

-- 
 \       “Repetition leads to boredom, boredom to horrifying mistakes, |
  `\       horrifying mistakes to God-I-wish-I-was-still-bored, and it |
_o__)              goes downhill from there.” —Will Larson, 2008-11-04 |
Ben Finney




More information about the Python-list mailing list