-
Notifications
You must be signed in to change notification settings - Fork 93
Nested steps
Vadzim Hushchanskou edited this page Mar 28, 2022
·
8 revisions
Nested steps is a common way to group your test logs into small described pieces. Here is how one of our internal test looks like:
Let's imagine we have a test for some products ordering flow:
import logging
from web import OrderingSimulator
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
order_simulator = OrderingSimulator()
def test_order_products():
product_count = 5
price = 3.0
total_price = price * product_count
logger.info('Main page displayed')
order_simulator.log_in()
logger.info('User logged in')
products = order_simulator.get_products()
logger.info('Products page opened')
product = order_simulator.choose_product()
logger.info("Product click event")
logger.info(str(product_count) + " products selected")
order_simulator.add_product(product, product_count)
logger.info(str(product_count) + " products added to the cart")
assert 5 == product_count
order_simulator.do_payment(total_price)
logger.info("Successful payment")
order_simulator.log_out()
logger.info("User logged out")
After running this method with our listener we have next results on the Report Portal page:
Pretty much stuff with different logic is included in the one single test function. So we can move different operations to separate functions: