Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #95543

Re: Parametrized Unit Tests

From Ben Finney <ben+python@benfinney.id.au>
Subject Re: Parametrized Unit Tests
Date 2015-08-22 11:42 +1000
References <f2d05b33-8755-4270-9bf4-b0b6153d13f7@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.9.1440207786.17298.python-list@python.org> (permalink)

Show all headers | View raw


rambius <rambiusparkisanius@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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Parametrized Unit Tests rambius <rambiusparkisanius@gmail.com> - 2015-08-21 08:17 -0700
  Re: Parametrized Unit Tests Laura Creighton <lac@openend.se> - 2015-08-21 17:42 +0200
  Re: Parametrized Unit Tests Ben Finney <ben+python@benfinney.id.au> - 2015-08-22 11:42 +1000
    Re: Parametrized Unit Tests rambius <rambiusparkisanius@gmail.com> - 2015-08-27 07:38 -0700
      Re: Parametrized Unit Tests Ben Finney <ben+python@benfinney.id.au> - 2015-08-28 09:46 +1000
        OFF-TOPIC Ben's sig monster quote [was Re: Parametrized Unit Tests] Steven D'Aprano <steve@pearwood.info> - 2015-08-28 16:26 +1000
          Re: OFF-TOPIC Ben's sig monster quote [was Re: Parametrized Unit Tests] Martin Skjöldebrand <martin@skjoldebrand.eu> - 2015-08-28 09:19 +0200
          Re: OFF-TOPIC Ben's sig monster quote [was Re: Parametrized Unit Tests] Ben Finney <ben+python@benfinney.id.au> - 2015-08-28 17:27 +1000
            Re: OFF-TOPIC Ben's sig monster quote [was Re: Parametrized Unit Tests] Marko Rauhamaa <marko@pacujo.net> - 2015-08-28 12:24 +0300
              Re: OFF-TOPIC Ben's sig monster quote [was Re: Parametrized Unit Tests] jmp <jeanmichel@sequans.com> - 2015-08-28 11:47 +0200
          Re: OFF-TOPIC Ben's sig monster quote [was Re: Parametrized Unit Tests] Steven D'Aprano <steve@pearwood.info> - 2015-08-29 00:02 +1000
            Re: OFF-TOPIC Ben's sig monster quote [was Re: Parametrized Unit Tests] Chris Angelico <rosuav@gmail.com> - 2015-08-29 01:07 +1000
          Re: OFF-TOPIC Ben's sig monster quote [was Re: Parametrized Unit Tests] Michael Torrie <torriem@gmail.com> - 2015-08-28 14:00 -0600
          Re: OFF-TOPIC Ben's sig monster quote [was Re: Parametrized Unit Tests] Rustom Mody <rustompmody@gmail.com> - 2015-08-29 21:34 -0700

csiph-web