Behaviour Driven Development BDD Logging

Learn the BELLATRIX Behaviour Driven Development BDD Logging works and how to use it.

Example

Feature: Navigate to BELLATRIX Online Rocket Shop
	To purchase a new rocket
	As a Nuclear Engineer 
	I want to be able to buy a new rocket.

Background:
Given I use app with path AssemblyFolder\Demos\ApiDemos.apk
And I restart the app on test fail
And I use device with name android25-test
And I use Android version 7.1
And I use app package com.example.android.apis
And I use app activity .view.Controls1
And I open app

Scenario: Successfully Transfer Item
	When I navigate to main page
	And I transfer item Jupiter user name antares password secret
	Then I assert that keep me logged is checked
    And I assert that permanent trasnfer is checked
    And I assert that Jupiter right item is selected
    And I assert that antares user name is set

Explanations

There cases when you need to show your colleagues or managers what tests do you have. Sometimes you may have manual test cases, but their maintenance and up-to-date state are questionable. Also, many times you need additional work to associate the tests with the test cases. Some frameworks give you a way to write human readable tests through the Gherkin language. The main idea is non-technical people to write these tests. However, we believe this approach is doomed. Or it is doable only for simple tests. This is why in BELLATRIX we built a feature that generates the test cases after the tests execution. After each action or assertion, a new entry is logged.

After the test is executed the following log is created:

Start Test
Class = BDDLoggingTests Name = CommonAssertionsAndroidControls
Ensure control(ID = button) is NOT disabled
Check control(ID = check1) on
Ensure control(ID = check1) is checked
Select 'Jupiter' from control (ID = spinner1) on
Click control(Text = Jupiter) on
Ensure control(ID = spinner1) text is 'Jupiter'
Ensure control(Text = textColorPrimary) is visible
Click control(ID = radio2) on
Ensure control(ID = radio2) is checked

Configuration

"logging": {
    "isEnabled": "true",
    "isConsoleLoggingEnabled": "true",
    "isDebugLoggingEnabled": "true",
    "isEventLoggingEnabled": "false",
    "isFileLoggingEnabled": "true",
    "outputTemplate":  "{Message:lj}{NewLine}",
}

In the testFrameworkSettings.json file find a section called logging, responsible for controlling the BDD logs generation. You can disable the logs entirely. There are different places where the logs are populated. By default, you can see the logs in the output window of each test. Also, a file called logs.txt is generated in the folder with the DLLs of your tests. If you execute your tests in CI with some CLI test runner the logs are printed there as well. outputTemplate - controls how the message is formatted. You can add additional info such as timestamp and much more. For more info visit- https://github.com/serilog/serilog/wiki/Formatting-Output