Skip to content

Step Comments (v1.x)

Suremaker edited this page Feb 28, 2017 · 2 revisions

Page version: 2.x / 1.x

Since version 1.7.0 it is possible to comment currently executed step by using StepExecution.Comment() or StepExecution.CommentFormat() methods. The usage of mentioned methods is valid only in a scope of test step and thread executing scenario - in all other situations, an exception would be thrown.

private void Given_product_is_in_stock()
{
	var product = "product";
	_stock.Add(product);
	StepExecution.CommentFormat("Added '{0}' to the stock", product);
}

private void When_customer_adds_it_to_the_basket()
{
	var product = "product";
	StepExecution.CommentFormat("Transferring '{0}' to the basket", product);
	_transferResult = _stock.TransferToBasket(_basket, product);
}

It is possible to comment given step multiple times.

All comments would be printed by ConsoleProgressNotifier:

SCENARIO: [Ticket-7] Successful addition
  STEP 1/5: GIVEN product is in stock...
  STEP 1/5: // Added 'product' to the stock //
  STEP 1/5: GIVEN product is in stock (Passed after 2ms)
  STEP 2/5: WHEN customer adds it to the basket...
  STEP 2/5: // Transferring 'product' to the basket //
  STEP 2/5: WHEN customer adds it to the basket (Passed after 123ms)
  STEP 3/5: THEN the product addition should be successful...
  STEP 3/5: THEN the product addition should be successful (Passed after 4ms)
  STEP 4/5: AND the basket should contain the product...
  STEP 4/5: AND the basket should contain the product (Passed after 1ms)
  STEP 5/5: AND the product should be removed from stock...
  STEP 5/5: AND the product should be removed from stock (Ignored after 1ms)
  SCENARIO RESULT: Ignored after 155ms
    Step 5: Product removal from stock is not implemented yet

All comments would be also included in summary reports (see example reports).

Continue reading: Test framework integrations

Clone this wiki locally