SetBatchId method

Class: BatchClose Platform: Appium Language: C# SDK:

Set the batch ID of the batches that should be closed.

Introduction

When closing a batch manually, this call is typically followed by a call to the method BatchClose.Close.

Syntax

EnabledBatchClose value = obj.SetBatchId(batchIds);

Parameters

batchIds
Type: string[]

One or more batches to be closed.

batchIds
Type: IEnumerable<string>

One or more batches to be closed.

Return value

Type: EnabledBatchClose
The returned object is an instance of a class inherited from BatchClose. This is to ensure that you only call BatchClose.Close if you've set the batch ID by calling SetBatchId

Example

The example below illustrates how to close a batch programmatically:

Note that the batch ID of the batch being closed needs to be passed to the BatchClose.SetBatchId method. In this example, we assume that a batch ID was set for all of the batches by assigning a unique ID to the environment variable APPLITOOLS_BATCH_ID. This is used as a default by the method Configuration.SetBatch which is set up in a suite Configuration object and assigned to each Eyes instance.

 
/*
 * Setup a common batch for all tests
 */
BatchInfo batchInfo = new BatchInfo(batchName);
batchInfo.Id = MyGetUniqueBatchID(); // User defined
suiteConfig = (Configuration) new Configuration() 
    .SetBatch(batchInfo)
    /* ... other configurations */; 
/* 
 * Assign the configuration to all newly created Eyes instances
 */
eyes = new Eyes();
eyes.SetConfiguration(suiteConfig);
/*
 * After all the tests have completed, in all the runners
 */
List<String> batchIds = new List<string>() { Environment.GetEnvironmentVariable("APPLITOOLS_BATCH_ID") };
BatchClose batchClose = new BatchClose();
batchClose.SetBatchId(batchIds).Close();