TestFairy allows developers to log items with a session, without logging to the console output. In some cases, there are work arounds that allow you to wrap the TestFairy remote logging method in a way that will both log to the console and to the session.

Syntax

TestFairy.log("<tag>", "<message>");

Code Example

// Be sure to import TestFairy
import com.testfairy.TestFairy;

TestFairy.log("Tag", "Hello, TestFairy!");
      

Syntax

TFLog(@"<message with format>", <arguments>);
[TestFairy log:@"<message>"];

Code Example

// Be sure to import TestFairy
#import "TestFairy.h"

TFLog(@"Hello, %@", @"TestFairy!");
[TestFairy log:@"Hello, TestFairy!"];
      

Syntax

TestFairy.log("<message>");

Code Example

TestFairy.log("Hello, TestFairy!");
      

We recommend wrapping all log statements with a custom method, which will output to both the console and to TestFairy sessions. One suggestion we have is to add a method that looks like this:

var _testfairyConsoleLog = console.log;
console.log = function(message) {
    _testfairyConsoleLog(message);
    TestFairy.log(message);
}
            

Syntax

TestFairy.log("<message>");

Code Example

// Be sure to import TestFairy
const TestFairy = require('react-native-testfairy');

TestFairy.log("Hello, TestFairy!");
      

We recommend wrapping all log statements with a custom method, which will output to both the console and to TestFairy sessions. One suggestion we have is to add a method that looks like this:

var _testfairyConsoleLog = console.log;
console.log = function(message) {
    _testfairyConsoleLog(message);
    TestFairySDK.log(message);
}
            

Syntax

TestFairySDK.log("<message>");

Code Example

// Be sure to import TestFairy
import { TestFairySDK } from 'nativescript-testfairy';

TestFairySDK.log("Hello, TestFairy!");
      

We recommend wrapping all log statements with a custom method, which will output to both the console and to TestFairy sessions. One suggestion we have is to add a method that looks like this:

var _testfairyConsoleLog = console.log;
console.log = function(message) {
    _testfairyConsoleLog(message);
    TestFairySDK.log(message);
}
            

We recommend wrapping all TFLog statements with a custom method, which will output to both the console and to TestFairy sessions. One suggestion we have is to add a method that looks like this:

Code Example

// Be sure to import TestFairy
using TestFairyLib;

public static void Log(string format, params object[] arg)
{
    using (var nsFormat = new NSString(string.Format(format, arg)))
    {
        CFunctions.TFLog(nsFormat.Handle, "");
        Console.WriteLine(string.Format(format, arg));
    }
}
      

Now, you can log statements using this call:

Log("Hello {0}", "World");
            

Syntax

TestFairy.log("<message>");

Code Example

// Be sure to import TestFairy
using TestFairyUnity;

TestFairy.log("Hello, TestFairy!");
      

Syntax

AirTestFairy.log("<message>");

Code Example

// Be sure to import TestFairy
import com.testfairy.AirTestFairy;

AirTestFairy.log("Hello, TestFairy!");
      

Syntax

TiTestFairy.log("<message>");

Code Example

// Be sure to import TestFairy
var TiTestFairy = require('com.testfairy.titestfairy');

TiTestFairy.log("Hello, TestFairy!");