April 2015
Intermediate to advanced
264 pages
5h 31m
English
We briefly explored data-driven tests earlier. Data-driven tests reduce the amount of boilerplate test code by allowing us to write a single test execution flow and run it with different combinations of data.
The following is an example using the nose2 parameterization plugin that we looked at earlier in this book:
from nose2.tools.params import params def given_a_series_of_prices(stock, prices): timestamps = [datetime(2014, 2, 10), datetime(2014, 2, 11), datetime(2014, 2, 12), datetime(2014, 2, 13)] for timestamp, price in zip(timestamps, prices): stock.update(timestamp, price) @params( ([8, 10, 12], True), ([8, 12, 10], False), ([8, 10, 10], False) ) def test_stock_trends(prices, expected_output): goog = Stock("GOOG") ...Read now
Unlock full access