Logging

Learn how to use the BELLATRIX logging library.

Example

[TestFixture]
public class LoggingTests : IOSTest
{
    [Test]
    public void ButtonClicked_When_CallClickMethod()
    {
        Logger.LogInformation("$$$ Before clicking the button $$$");
        var button = App.Components.CreateByName<Button>("ComputeSumButton");

        button.Click();
    }
}

Explanations

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

Logger.LogInformation("$$$ Before clicking the button $$$");

Sometimes is useful to add information to the generated test log. To do it you can use the BELLATRIX built-in logger through accessing it via Logger static class.

Generated Log, as you can see the above custom message is added to the log.

Start Test
Class = LoggingTests Name = ButtonClicked_When_CallClickMethod
$$$ Before clicking the button $$$
Click control(Name = ComputeSumButton)