An open API service indexing awesome lists of open source software.

https://github.com/geekie/datadriven

Run a test case multiple times with different data
https://github.com/geekie/datadriven

datadriven python testing

Last synced: 11 months ago
JSON representation

Run a test case multiple times with different data

Awesome Lists containing this project

README

          

# datadriven

datadriven allows you to run a test case multiple times with different data. It was designed to work
with `unittest.TestCase` test methods, any test runner (nose, nose2, unittest, unittest2 and
pytest), in Python 2.7 or 3.7+.

## Usage

```py
import datadriven

class SomeTestCase(unittest.TestCase):

@datadriven.datadriven(
caseA=datadriven.Args(first="foo"),
caseB=datadriven.Args("hello", second="world"),
)
def test_method(self, first, second=None):
...
```

This is the equivalent of writing:

```py
import datadriven

class SomeTestCase(unittest.TestCase):

def test_method(self, first, second=None):
...

def test_method_caseA(self):
self.test_method("foo")

def test_method_caseB(self):
self.test_method("hello", "world")
```

The only difference is that when wrapped with `@datadriven`, the test `test_method` won't be really executed.

## License

[Apache-2.0 License](./LICENSE)